简体   繁体   中英

How to do “select * from table” in DynamoDb?

I'm looking through the tutorials and they all seem to be querying with some sort of condition. How can I just get ALL the items in the db?

Perform a SCAN operation for full table scan. You have the option to add filters to the scan.

SCAN may not be as good as you may imagine. Firstly, it only scans at most 1MB of data at one time. You may make additional calls if you want more data. Besides, this 1MB limitation is applied before filtering. That is to say every SCAN looks up to 1MB of data and filter based on your criteria, instead of keep scanning while filtering until 1MB limitation is reached.

Also, SCAN may cause sudden burst of read activity. Say if your record is 1KB and you make SCAN every one second, then a SCAN can return up to 1000 records, which consumes 500 read capacity. You may want to set a limit smaller than the default 1MB when doing the scan.

Lastly, SCAN doesn't guarantee the order of result. You can't specify an 'order by', and no assumption should be made on the order it returns.

DynamoDB is made for storing key-value data. You are supposed to query the value by key. If you are not always querying the primary key and get a unique record, you may add global secondary indexes which gives you the ability to query by two columns and order by one of them.

Please refer to AWS documentation: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html

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