John Mee
John Mee

Reputation: 52243

For aws dynamodb, does a scan of the hash_key use an index?

The hash_key takes the form of daily|<YYYY-MM-DD>.

Whats the most efficient way to fetch a range of dates?

We cannot do a query. Well not for the whole resultset in one go. Although a loop and a series of queries for each exact key might be the 'correct' answer? Is that the best solution?

If we do a scan on the hash_key, would it use an index? Would that actually be somewhat efficient? eg: hash_key in ('daily|2022-12-07', 'daily|2022-12-08')

The sort_key is a user identity_id.

Upvotes: 0

Views: 266

Answers (1)

hunterhacker
hunterhacker

Reputation: 7132

Best approach is to do a query for each PK, possibly in parallel. If the average item collection size is large this is even pretty efficient.

Think of DynamoDB like a hashtable storing sorted lists. You want all the values associated with certain hash table keys. So you need to do the lookups.

Upvotes: 1

Related Questions