DynamoDB: slow reading on request for the first time
Below 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. Reading - 6 views / sec.
Error log output
before the request 16: 05: 29: 0229
after the request 16: 05: 32: 0232
Question: What took 3 seconds to read the user for the first time? If I add another request after the first request, it will take less than 1 second to respond.
Any light on the way would be helpful
-Thank
This can happen if you run this query from different regions than a database instance or from a local one.
If you did not upload the file with this request to the same region as your dynamoDb, it will take some time to create a connection to your database instance. Try downloading this script on the same server in the region as your database, and then try again.