Dynamodb hard
An architect creates a GSI with `ProjectionType: KEYS_ONLY`. During a Query on this GSI, the application requests an attribute that exists in the base table but was NOT projected. What is the technical result?
- A DynamoDB performs a 'Live Joint' (internal fetch) to the base table to retrieve the attribute, doubling the latency.
- B The request fails with a `ValidationException`. Unlike relational databases, DynamoDB does not 'join' back to the base table; the data must be present in the index to be retrieved via index-query.
- C It returns the attribute as a null value without error.
- D The request succeeds, but the attribute is fetched from the DAX cache only.
Answer: B. The request fails with a `ValidationException`. Unlike relational databases, DynamoDB does not 'join' back to the base table; the data must be present in the index to be retrieved via index-query.
DynamoDB's GSIs are strictly independent 'Projections'. There is no pointer-chasing back to the base table during a Query to ensure O(1) performance. If you need 10 attributes in your result, all 10 must be projected into the GSI (`INCLUDE`) or the entire item must be projected (`ALL`). Projection choices are critical trade-offs between storage cost and query flexibility.
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?