A DynamoDB table named orders has a primary partition key id and a global secondary index accountIndex with partition key accountId and sort key orderDateTime. A Lambda function must retrieve the orders for accountId = 100. Which DynamoDB API call will return those items using the least read capacity?
Choose an answer
Tap an option to check your answer.
Correct answer: Use the Query API call on the accountIndex GSI specifying accountId = 100..
Why this is the answer
The Query API call on the accountIndex GSI (Global Secondary Index) with accountId = 100 is the most efficient method. A GSI allows you to query data using attributes other than the table's primary key. Since accountId is the partition key of accountIndex, a Query operation can directly access all items for that specific accountId, making it highly efficient and consuming minimal read capacity. Using GetItem or BatchGetItem is incorrect because they require the primary key (id) of the main table, which is not known when searching by accountId. A Scan operation would read every item in the entire table and then filter them, making it very inefficient and expensive in terms of read capacity, especially for large tables.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed