Question

Following is my code :

error_log('before query'.date("H:i:s:ms"));
$response = $client->query(array(
                                 "TableName" => "user",
                                 "KeyConditions" => array(
                                 "userId" => array( "ComparisonOperator" => ComparisonOperator::EQ,
                                 "AttributeValueList" => array(
                                                               array(Type::NUMBER => 2)
                                                               ))),
                                ));
error_log('after query'.date("H:i:s:ms"));
print_r($response);

My tables Read capacity is 6 reads/sec

Output of Error logs

before query 16:05:29:0229

after query 16:05:32:0232

Question: Why it took 3 secs to read the user for first time? If I add one more query after my first query then it take less than 1 sec to respond.

Any light on the path would be helpful

-Thanks

Was it helpful?

Solution

This can happen if you are executing this query from different region than database's instance or from local.

If you haven't uploaded file with this query to the same region as your dynamoDb then it will take some time to build connection with your DB instance. Try to upload this script on the same region's server as your DB and then try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top