DynamoDB query() versus getItem() for single-item retrieval based on the index

ensnare picture ensnare · Sep 3, 2012 · Viewed 22.6k times · Source

If I'm retrieving a single item from my table based on the indexed hash key, is there a performance difference between query() or getItem()?

Answer

Chen Harel picture Chen Harel · Sep 3, 2012

getItem will be faster
getItem retrieve via hash and range key is a 1:1 fit, the time it takes (hence performance) to retrieve it is limited by the hash and sharding internally.
Query results in a search on "all" range keys. It adds computational work, thus considered slower.