What is the difference between scan and query in dynamodb? When use scan / query?

前端 未结 5 1509
小蘑菇
小蘑菇 2020-12-05 04:05

A query operation as specified in DynamoDb documentation:

A query operation searches only primary key attribute values and supports a subset of compar

5条回答
  •  遥遥无期
    2020-12-05 04:26

    Query is much better than Scan - performence wise. scan, as it's name imply, will scan the whole table. But you must be well aware of the table key, sort key, indexes and and related sort indexes in order to know that you can use the Query. if you filter your query using:

    • key
    • key & key sort
    • index
    • index and it's related sort key

    use Query! otherwise use scan which is more flexible about which columns you can filter.

    you can NOT Query if:

    • more that 2 fields in the filter (e.g. key, sort and index)
    • sort key only (of primary key or index)
    • regular fields (not key, index or sort)
    • mixed index and sort (index1 with sort of index2)\
    • ...

    a good explaination: https://medium.com/@amos.shahar/dynamodb-query-vs-scan-sql-syntax-and-join-tables-part-1-371288a7cb8f

提交回复
热议问题