Che*_*rel 18 java amazon-web-services amazon-dynamodb
我有一个带有散列和范围复杂键的表.
我可以使用GetItemAWS SDK for Java 查询项目.将GetItem返回null如果没有找到对象,或作为项目Map<String, AttributeValue>.
我正在寻找最快的方法来检查对象是否存在
我正在考虑提供.withAttributesToGet如下:
GetItemResult result = dbClient.getItem(new GetItemRequest().
withTableName(TABLE_NAME).
withKey(new Key(new AttributeValue().withS(hashKey),
new AttributeValue().withS(rangeKey))).
withAttributesToGet(new ArrayList<String>()));
Map<String, AttributeValue> item = result.getItem();
return (item != null);
Run Code Online (Sandbox Code Playgroud)
另一个优化是不使用SDK JSON解析器并自己解析响应以快速检查项目是否已返回.
谢谢
Son*_*van 18
我认为"获取"和检查它是否存在之间的速度差别可以忽略不计.您可以继续使用GetItem本身.如果项目可能太大,则限制返回的属性.
瓶颈在延迟时间内到达Dynaamo数据库服务器(REST API)并从索引中获取.所以获取和检查将是类似的速度.确保发出呼叫的服务器与Dynamo DB位于同一区域 - 这对速度有最大影响.
| 归档时间: |
|
| 查看次数: |
18666 次 |
| 最近记录: |