Reputation: 6800
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).
Upvotes: 0
Views: 939
Reputation: 14869
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
Upvotes: 1