Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the row count of a table instantly in DynamoDB?

Tags:

I'm using boto.dynamodb2, and it seems I can use Table.query_count(). However it had raised an exception when no query filter is applied.

What can I do to fix this?

BTW, where is the document of filters that boto.dynamodb2.table.Table.Query can use? I tried searching for it but found nothing.

like image 802
Kane Blueriver Avatar asked Jul 13 '15 08:07

Kane Blueriver


1 Answers

There are two ways you can get a row count in DynamoDB.

The first is performing a full table scan and counting the rows as you go. For a table of any reasonable size this is generally a horrible idea as it will consume all of your provisioned read throughput.

The other way is to use the Describe Table request to get an estimate of the number of rows in the table. This will return instantly, but will only be updated periodically per the AWS documentation.

The number of items in the specified index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

like image 79
JaredHatfield Avatar answered Oct 08 '22 11:10

JaredHatfield