Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCAN on key attribute in DynamoDB

I need to execute an in query on the key attribute. Since, query doesn't provide in condition, I am planning to use scan. Will scan on key attribute scan the entire table?

like image 598
Réti Opening Avatar asked Feb 09 '12 06:02

Réti Opening


People also ask

What is the use of Scan item option in DynamoDB?

A Scan operation in Amazon DynamoDB reads every item in a table or a secondary index. By default, a Scan operation returns all of the data attributes for every item in the table or index. You can use the ProjectionExpression parameter so that Scan only returns some of the attributes, rather than all of them.

What is a Scan in DynamoDB?

PDF. The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index. To have DynamoDB return fewer items, you can provide a FilterExpression operation.

What is difference between Scan and Query in DynamoDB?

DynamoDB supports two different types of read operations, which are query and scan. A query is a lookup based on either the primary key or an index key. A scan is, as the name indicates, a read call that scans the entire table in order to find a particular result.

Can we Query on sort key in DynamoDB?

You can not query only using a Sort Key. You need to specify a partition key to perform query operations. Else, you need to create a global secondary index or perform a scan operation.


1 Answers

Will SCAN on key attribute scan the entire table?

Yes, see Query and Scan in Amazon DynamoDB:

Scan

A scan operation scans the entire table. You can specify filters to apply to the results to refine the values returned to you, after the complete scan. Amazon DynamoDB puts a 1MB limit on the scan (the limit applies before the results are filtered). A scan can result in no table data meeting the filter criteria.

Specifically, there is no difference between key and non key attributes as far as the Scan API is concerned, i.e. you simply provide the desired attributes by name, regardless of them being used as an attribute constituting the Primary Key as well or not:

AttributesToGet

Array of Attribute names. If attribute names are not specified then all attributes will be returned. If some attributes are not found, they will not appear in the result.

like image 76
Steffen Opel Avatar answered Sep 28 '22 10:09

Steffen Opel