AWS Certified Developer Associate · Free Practice Question Medium
Question 3
A nightly batch job loads 1 million new records in to a DynamoDB table. The records are only needed for one hour, and the table needs to be empty by the next night’s batch job.
Which is the MOST efficient and cost-effective method to provide an empty table?
-
A
Use BatchWriteItem to empty all of the rows
-
B
Use
DeleteItemusing aConditionExpression -
C
Create and then delete the table after the task has completed
-
D
Write a recursive function that scans and calls out
DeleteItem
Reveal correct answer
Correct answer: C
Explanation
The key requirements here are to be efficient and cost-effective. Therefore, it’s important to choose the option that requires the fewest API calls. As the table is only required for a short period of time, the most efficient and cost-effective option is to simply delete and recreate the table.
The following API actions can be used to perform this operation programmatically:
· CreateTable - The CreateTable operation adds a new table to your account.
· DeleteTable - The DeleteTable operation deletes a table and all of its items.
This solution means fewer API calls and also the table is not consuming RCUs/WCUs whilst not being used. Therefore, the best option is to create and then delete the table after the task has completed.
CORRECT: "Create and then delete the table after the task has completed" is the correct answer.
INCORRECT: "Use DeleteItem using a ConditionExpression" is incorrect as this will use more RCUs and WCUs and is not cost-effective.
INCORRECT: "Use BatchWriteItem to empty all of the rows" is incorrect. The BatchWriteItem operation puts or deletes multiple items (not rows) in one or more tables. This would use more RCUs and WCUs and is not cost-effective.
INCORRECT: "Write a recursive function that scans and calls out DeleteItem" is incorrect as scans are the least efficient and cost-effective option as all items must be retrieved from the table.
References:
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Operations.html
Save time with our AWS cheat sheets:
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
