简体   繁体   English

是否在DynamoDB中不传递主键的情况下相当于选择查询?

[英]Equivalent of select query without passing primary key in DynamoDB?

What will be the equivalent of below query in DynamoDB: DynamoDB中的以下查询将等效于什么:

select field1,fields2 from table_name where filter1 == 'filter_value'

Please note that filter1 is not the primary key here, it can be any column in the table. 请注意,此处的filter1不是主键,它可以是表中的任何列。

From what I have read, I understand that it can be achieved using scan() operation but it will return whole data not just fields we specify. 从我的阅读中,我理解可以使用scan()操作来实现它,但是它会返回整个数据,而不仅仅是我们指定的字段。
Also, I have read everywhere that we should avoid using scan() as it is heavy operation (scans whole table). 另外,我到处都读到我们应该避免使用scan(),因为它是繁重的操作(扫描整个表)。

Using the AWS Command Line Interface, you would do it like this 使用AWS命令行界面,您可以这样做

aws dynamodb scan \
     --table-name table_name\
     --projection-expression "field1,fields2" \
     --filter-expression "filter1 = :filter_value"\

A scan always reads every row in the database. 扫描总是读取数据库中的每一行。 A filter expression simply limits what is returned to you. 过滤器表达式仅限制返回给您的内容。 By default you get all attributes ('columns') back for each item but you can limit that using a projection expression. 默认情况下,您可以获取每个项目的所有属性(“列”),但可以使用投影表达式对其进行限制。

Queries can be used when you are searching on an indexed attribute. 在搜索索引属性时可以使用查询。

For information checkout the docs on scans and query 有关信息,请检查有关扫描查询的文档

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM