What should the developer do to get the relevant data MOST efficiently?
Perform a scan on the Events table by using the partition key and the sort key as filter expressions.
Perform a query on the Events table by using the partition key and the sort key as filter expressions.
Perform a scan on the Events table by using the partition key and the sort key in a key condition expression.
Perform a query on the Events table by using the partition key and the sort key in a key condition expression.
Explanations:
Performing a scan on the Events table is not efficient because it reads every item in the table and applies filter expressions after retrieving the data. This approach is slower and more costly, especially for large tables. Using filter expressions does not take advantage of the table’s indexed structure.
While the intention to use a scan with filter expressions is noted, a query requires using the key condition expression to specify both the partition and sort key to fetch items efficiently. Filter expressions are not suitable in this context, as they are evaluated after data retrieval.
Similar to option A, performing a scan is not an efficient method. Even though it mentions using a key condition expression, scans read the entire table, making this approach slow and not ideal for retrieving specific items.
This option is correct because performing a query on the Events table with the partition key (event date) and sort key (user’s unique ID) in a key condition expression is the most efficient method. It directly accesses the relevant items without scanning the entire table, resulting in faster response times and lower read costs.