What's the difference between BatchGetItem and Query in DynamoDB?

后端 未结 4 1801
耶瑟儿~
耶瑟儿~ 2020-12-08 06:47

I\'ve been going through AWS DynamoDB docs and, for the life of me, cannot figure out what\'s the core difference between batchGetItem() and Query(). Both retrieve items bas

4条回答
  •  甜味超标
    2020-12-08 07:05

    In a nutshell: BatchGetItem works on tables and uses the hash key to identify the items you want to retrieve. You can get up to 16MB or 100 items in a response

    Query works on tables, local secondary indexes and global secondary indexes. You can get at most 1MB of data in a response. The biggest difference is that query support filter expressions, which means that you can request data and DDB will filter it server side for you.

    You can probably achieve the same thing if you want using any of these if you really want to, but rule of the thumb is you do a BatchGet when you need to bulk dump stuff from DDB and you query when you need to narrow down what you want to retrieve (and you want dynamo to do the heavy lifting filtering the data for you).

提交回复
热议问题