'How to fetch table data from AWS DynamoDB using python, optimally?

I am trying to fetch table data from Amazon DynamoDB and am currently using boto3 library for the same. Currently, I'm using scan() method.

But, I see that scan() is the most time-consuming and most expensive way to access data in DynamoDB as the search is sequential. Scans are also slow especially with large tables and most likely we will consume all the provisioned throughput within no time, so for that reason, I have 2 queries regarding the same:

  • How do we fetch all the table data and store it in a pandas dataframe?
  • How to fetch only the TOP TEN records from a table?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source