Dynamodb medium
A developer uses a `FilterExpression` in a `Scan` to find users where `Age > 18`. Why does this NOT reduce the Read Capacity Unit (RCU) consumption of the request?
- A Because DynamoDB only counts the write cost, never the read cost, for filters.
- B Evaluation Order: DynamoDB reads all the items from the disk first (consuming RCUs), and then filters them at the API layer before returning the result to the client. You are charged for every item read, even if it is discarded by the filter.
- C Filters are only applied to the GSI, not the base table.
- D Filters actually increase RCU because the database has to perform additional math operations.
Answer: B. Evaluation Order: DynamoDB reads all the items from the disk first (consuming RCUs), and then filters them at the API layer before returning the result to the client. You are charged for every item read, even if it is discarded by the filter.
Filters are a convenience for network bandwidth, not for cost. To save money and RCUs, you must use a `KeyConditionExpression` with a Sort Key or a Secondary Index, which narrows down the data *before* it is read from the physical disk.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- DynamoDB has a strict 400KB limit on the size of a single item. What is the recommended design pattern if you need to store larger documents (e.g., 5MB PDFs)?
- What is the primary role of the 'Partition Key' in ensuring DynamoDB's infinite horizontal scalability?
- Why is the `Query` operation generally preferred over `Scan` for production workloads in DynamoDB?
- DynamoDB is a 'fully managed' serverless database. What is a primary operational benefit of this model for an engineering team?
- In 'Provisioned Capacity' mode, how is the performance budget of a DynamoDB table defined?
- When would an architect choose to implement DAX (DynamoDB Accelerator) in front of an existing DynamoDB table?