简体   繁体   English

DynamoDB查询和分区键,简单问题

[英]DynamoDB query & partition keys, simple question

something I don't understand about querying a dynamoDB table is that it seems necessary to include something like .withKeyConditionExpression("itemId = :v_id") , but since the partition key uniquely identifies all items in the table, wouldn't you always be searching just one result? 对于查询dynamoDB表,我不了解的地方似乎是需要包含类似.withKeyConditionExpression("itemId = :v_id") ,但是由于分区键唯一地标识了表中的所有项,因此您不会总是仅搜索一个结果?

Trying to do something like: 尝试做类似的事情:

val expression = DynamoDBQueryExpression<PluginItem>()
                .withKeyConditionExpression("itemId > 0")
                .withFilterExpression("attributes.item_modification_date < :val1")
                .withExpressionAttributeValues(eav)
val paginatedResults = queryByExpression(expression)

I'm looking to query and paginate 100,000 items in the table, can anyone point me in the right direction? 我正在查询表中的100,000个项目并对其分页,有人可以向我指出正确的方向吗?

partition key uniquely identifies all items in the table 分区键唯一标识表中的所有项目

so this isn't accurate. 所以这是不准确的。 It depends on your table design. 这取决于您的桌子设计。 However, you will get a lot more fexibility if you design a table with a ParitionKey and a Sort Key. 但是,如果设计具有ParitionKey和Sort Key的表,则将具有更多的灵活性。 That said, back to your statement. 就是说,回到您的声明。 A Primary Key not a partition key uniquely identifies an item in the table. 主键而不是分区键唯一地标识表中的项目。 A primary key is a combination of ParitionKey + SortKey(also known as Range Key). 主键是ParitionKey + SortKey(也称为范围键)的组合。

Think of each partition as a bucket. 将每个分区都视为一个存储桶。

withKeyConditionExpression("itemId > 0") withKeyConditionExpression(“ itemId> 0”)

this won't work. 这行不通。 You can't do those kinds of operations on a partition key. 您不能对分区键执行这些类型的操作。 However, you can do those kinds of conditions on a sort key. 但是,您可以在排序键上执行这些条件。

a video from 2018 - re:Invent that helped me get a better understanding of Dynamo. 来自2018年的视频-re:Invent帮助我更好地了解了Dynamo。 I have watched that video quite a few times, especially the last 30 to 20mins of it. 我看了好几次视频,尤其是最后30到20分钟。

Hope that helps. 希望能有所帮助。 I have only been working with dynamodb for a few months and there is so much more I have to learn. 我仅与dynamodb一起工作了几个月,还有很多东西我需要学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在dynamoDb中查询包含特定子字符串的分区键? - How do I query for a partition keys that contain a specific substring in dynamoDb? 如何使用其他分区键查询 dynamoDB - How to query dynamoDB using other partition key 关于数据库查询的简单问题 - Simple question on database query 使用多个排序键查询 Dynamodb - Query Dynamodb with more than one sort keys 有没有办法在 DynamoDB 中查询多个 hash 键? - Is there a way to query multiple hash keys in DynamoDB? 如何基于分区键和排序键查询DynamoDB [Java]? - How to query DynamoDB based on Partition Key and Sort Key [Java]? 具有不同分区键的表上的Cassandra批处理查询性能 - Cassandra batch query performance on tables having different partition keys 在 Spring 上,如何使用 JPA 和复合键(分区键和排序键)查询 DynamoDB 表? - On Spring, how to query DynamoDB table using JPA and a composite key (Partition Key and Sort Key)? 使用 Java SDK 2 查询超过 100 个与分区键匹配的 DynamoDB 项目? - Query More Than 100 DynamoDB Items that match a Partition Key using Java SDK 2? 一个简单的问题:如何获取Java中要用于GQL查询的当前日期? - Simple Question: How to get current date in Java to be used in GQL query?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM