DynamoDB:第一次查询时读慢 [英] DynamoDB : Slow Read when queried for first time

查看:152
本文介绍了DynamoDB:第一次查询时读慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码:

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);

我的表读取容量为6次读取/秒

My tables Read capacity is 6 reads/sec

错误日志的输出

在查询16:05:29:0229之前

before query 16:05:29:0229

查询后16:05:32:0232

after query 16:05:32:0232

问题:为什么第一次读取用户需要3秒钟?如果我在第一个查询之后又添加了一个查询,则响应时间不到1秒。

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

-谢谢

推荐答案

如果从数据库实例以外的其他区域执行此查询,则可能会发生这种情况或从本地。

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

如果您尚未将此查询文件上传到与dynamoDb相同的区域,则将需要一些时间来建立与数据库实例的连接。尝试将此脚本与您的数据库上传到同一区域的服务器上,然后重试。

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.

这篇关于DynamoDB:第一次查询时读慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆