Which statement best describes the main difference between a Scan and a Query operation in DynamoDB?
Think about how each operation accesses data and what keys they use.
A Scan reads every item in the table and then applies filters, which can be slow. A Query uses the primary key or an index to find matching items quickly.
Given a DynamoDB table with 1000 items, 100 of which have a partition key value of 'user123'. What is the expected number of items returned by a Query with partition key 'user123' vs a Scan with a filter for 'user123'?
Consider how many items each operation reads and returns.
The Query directly fetches the 100 matching items. The Scan reads all 1000 items and then filters to return 100.
Which of the following DynamoDB Query API calls is syntactically correct to fetch items with partition key 'user123'?
const params = {
TableName: 'Users',
KeyConditionExpression: 'userId = :uid',
ExpressionAttributeValues: {
':uid': 'user123'
}
};
const result = await dynamodb.query(params).promise();Check the syntax for KeyConditionExpression and how values are referenced.
KeyConditionExpression uses a single equals sign and placeholders like ':uid' must be defined in ExpressionAttributeValues. Option D follows this correctly.
You want to reduce the read capacity units consumed by a Scan operation that filters items by an attribute 'status'. Which approach will improve performance?
Think about how to reduce the amount of data scanned and speed up the operation.
FilterExpression reduces returned items but does not reduce read units. Parallel Scan divides the table into segments scanned concurrently, improving speed.
A DynamoDB Query on a large table is unexpectedly slow. The Query uses a partition key but no sort key condition. Which is the most likely cause?
Consider how the absence of a sort key condition affects the number of items returned.
Without a sort key condition, the Query returns all items with the partition key, which can be many and slow the response.