Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amazon dynamodb query without primary key knowledge

I am using amazon dynamodb boto query interface for python. I have the following questions

  1. How can I get all the primary keys in the database?
  2. How can I get , lets say 1000 primary keys. Then stop and then get the next 1000 primary keys. I don't know the primary keys beforehand.It's sort of like sampling without replacement for primary keys.

For me it seems that the the querying is using the assumption that the user knows the primary keys beforehand.

Thanks!

like image 826
mathopt Avatar asked Dec 22 '14 08:12

mathopt


1 Answers

Query requires that you specify the hash key.

For the case you are trying to achieve, you need to evaluate every item in the table which requires you to use a Scan.

It sounds to me like you have 3 requirements:

  1. Evaluate every item in the table
  2. Limit each fetch to 1000 items
  3. Only get the hash/range key for each item

These 3 requirements map well into DynamoDB:

  1. Scan API:

    The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index...

  2. Limit request parameter :

    The maximum number of items to evaluate (not necessarily the number of matching items)...

  3. ProjectionExpression request parameter:

    A string that identifies one or more attributes to retrieve from the specified table or index...

like image 109
mkobit Avatar answered Sep 18 '22 13:09

mkobit