简体   繁体   中英

AWS DynamoDB Query Call (with no results) Cost

I'm currently working out if I will use DynamoDB for some of a Project. I want to know if I execute a query against the Database for a specific Key and it isn't found (eg: see if this UserID is present and get contents if it is) is this Query that returns no results considered a Read and Chargeable?

I expect I will do a certain amount of queries that won't return results (polling for information) and need to factor this in.

Below is from the AWS website: http://aws.amazon.com/dynamodb/pricing/

"Note that the required number of units of Read Capacity is determined by the number of items being read per second, not the number of API calls. For example, if you need to read 500 items per second from your table, and if your items are 1KB or less, then you need 500 units of Read Capacity. It doesn't matter if you do 500 individual GetItem calls or 50 BatchGetItem calls that each return 10 items."

You can simply check it by calling DynamoDB and looking at ConsumedCapacityUnits in the result.

For example, if you are calling a simple getItem call for an item that exists, you get something like:

Result: {Item: {fans={SS: [Billy Bob, James], }, name={S: Airplane, }, year={N: 1980, }, rating={S: *****, }}, 
  ConsumedCapacityUnits: 0.5, }

However, when you are calling it on an item that doesn't exist, you get:

Result: {ConsumedCapacityUnits: 0.5, }

Therefore, it appears that you are consuming your capacity even if the item is not in the table, as the lookup is running nevertheless

According to this link , there's a difference between Scan and Query operations. A query with no result will not result in any cost.

To provide a more specific answer, the query operation does get billed even if you don't get any results back (the accepted answer covers the getItem operation).

According to the current documentation , all items returned are treated as a single read operation, where DynamoDB computes the total size of all items and then rounds up to the next 4 KB boundary. Therefore, your 0 KB result would be rounded up to 4 KB and be billed as 0.5 or 1 read capacity unit , depending on your billing plan.

Below is a screenshot from my test database.

没有返回结果的查询

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM