![how to use sql on mac to communicate with aws dynamo how to use sql on mac to communicate with aws dynamo](https://miro.medium.com/max/747/1*xJH0mo_Ms81mSRU3sgVVSA.png)
These tables can then contain entries for number of items per table, per collection or items matching with some criteria.
#How to use sql on mac to communicate with aws dynamo update
You can then keep this Table possibly named "TotalNumberOfItemsPerTable" updated by making atomic update operations to increment/decrement the total item count for a particular table.įurthermore, you can expand this concept to even further granularity for example to maintain total number of items matching with some hash key or any arbitrary criteria which you can encode in string form to make an entry in your table named something like "TotalNumberOfItemsInSomeCollection" or "TotalNumberOfItemsMatchingSomeCriteria". This will require to write a custom query logic and handle inevitable throttling in query operations.Ī better solution that comes to my mind is to maintain the total number of item counts for such tables in a separate table, where each item will have Table name as it's hash key and total number of items in that table as it's non-key attribute. And even considering the fact that scan will limit the resultant count by size of 1MB, you will have to make repeated scan operations to get the actual number of items if the table is very large. But remember that scan operation literally scans through the whole table and therefore consumes lots of throughput, so all the query operations will receive Throttled Exception in that duration. Now one way to achieve this is by using scan operation. If you are interested in using the total number of items in a table in your application's logic, that means you are going to query for the total counts pretty frequently. The only issue is that the count isn't up to date.
![how to use sql on mac to communicate with aws dynamo how to use sql on mac to communicate with aws dynamo](https://miro.medium.com/max/288/1*UKyCINGoe1P906ThZKdfWA.png)
The simplest solution is the DescribeTable which returns ItemCount. If you need pin-point accuracy, use a conditional update instead. So if a write fails or you write more than once this will be reflected in the count. The only problem this is that increment operations are not idempotent. Update operations to increment/decrement the total item count for a Possibly named "TotalNumberOfItemsPerTable" updated by making atomic Item will have Table name as it's hash key and total number of items Number of item counts for such tables in a separate table, where each The second option is what was mention by Atharva:Ī better solution that comes to my mind is to maintain the total The first option is using the scan, but the scan function is inefficient and is in general a bad practice, especially for tables with heavy reads or production tables. I can think of three options to get the total number of items in a DynamoDB table.