简体   繁体   中英

Equivalent of select query without passing primary key in DynamoDB?

What will be the equivalent of below query in 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.

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.
Also, I have read everywhere that we should avoid using scan() as it is heavy operation (scans whole table).

Using the AWS Command Line Interface, you would do it like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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