Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB SCAN operation cost with "Limit" parameter

I'm pretty new to AWS DynamoDB and having read the documentation I'm not 100% sure what happens to cost calculations when using the 'Limit' parameter in a SCAN operation.

I understand that one should design the tables so that QUERY operations are predominantly used and that a SCAN will scan the entire table, thus consuming a lot of read capacity. I also understand that a FilterExpression doesn't affect that cost of scanning the entire table, but filters what is returned after the entire scan, and if the total number of scanned items exceeds the maximum data set size limit of 1 MB, the scan stops and results are returned.

What I'm not sure of, is whether the 'Limit' parameter is a type of FilterExpression, or whether it stops an entire scan, thus reducing read costs.

For example, if I had an activity table with a sort key that is a date field (updatedAt) and it had a million rows. If I performed a SCAN with a Limit = 10 (in order to get the very latest 10 activities), I would obviously get back 10 rows but would I be charged for reading a million rows? Cost is my main concern.

like image 705
elprl Avatar asked May 06 '16 13:05

elprl


1 Answers

Yes, Limit will also rediuce the consumed read capacity, here is the relevant part from the DynamoDB docs:

The Scan operation provides a Limit parameter that you can use to set the page size for your request. Each Scan or Query request that has a smaller page size uses fewer read operations and creates a "pause" between each request. For example, if each item is 4 KB and you set the page size to 40 items, then a Query request would consume only 40 strongly consistent read operations or 20 eventually consistent read operations. A larger number of smaller Scan or Query operations would allow your other critical requests to succeed without throttling.

As you can see each Scan or Query request that has a smaller page size uses fewer read operations.

like image 149
Boris Serebrov Avatar answered Oct 20 '22 00:10

Boris Serebrov