0
0
DynamoDBquery~20 mins

Scan vs Query performance comparison in DynamoDB - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DynamoDB Scan vs Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Scan vs Query in DynamoDB

Which statement best describes the main difference between a Scan and a Query operation in DynamoDB?

AScan reads all items in a table and filters results, while Query finds items based on primary key values.
BScan only reads items with a specific attribute, Query reads all items.
CScan and Query both read all items but Query is faster because it uses indexes.
DQuery reads all items in a table and filters results, while Scan finds items based on primary key values.
Attempts:
2 left
💡 Hint

Think about how each operation accesses data and what keys they use.

query_result
intermediate
2:00remaining
Result count difference between Scan and Query

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'?

AQuery returns 100 items; Scan returns 1000 items.
BQuery returns 1000 items; Scan returns 100 items.
CQuery returns 100 items; Scan reads 1000 items but returns 100 after filtering.
DQuery returns 1000 items; Scan reads 1000 items but returns 100 after filtering.
Attempts:
2 left
💡 Hint

Consider how many items each operation reads and returns.

📝 Syntax
advanced
2:00remaining
Identify the correct Query syntax in DynamoDB

Which of the following DynamoDB Query API calls is syntactically correct to fetch items with partition key 'user123'?

DynamoDB
const params = {
  TableName: 'Users',
  KeyConditionExpression: 'userId = :uid',
  ExpressionAttributeValues: {
    ':uid': 'user123'
  }
};

const result = await dynamodb.query(params).promise();
AFilterExpression: 'userId = :uid', ExpressionAttributeValues: { ':uid': 'user123' }
BKeyConditionExpression: 'userId == :uid', ExpressionAttributeValues: { ':uid': 'user123' }
CKeyConditionExpression: 'userId = user123', ExpressionAttributeValues: { ':uid': 'user123' }
DKeyConditionExpression: 'userId = :uid', ExpressionAttributeValues: { ':uid': 'user123' }
Attempts:
2 left
💡 Hint

Check the syntax for KeyConditionExpression and how values are referenced.

optimization
advanced
2:00remaining
Improving Scan performance with filters

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?

AUse a FilterExpression in Scan to filter 'status' and enable Parallel Scan with segments.
BUse Query instead of Scan without any indexes.
CRemove the FilterExpression and scan the entire table sequentially.
DUse Scan with FilterExpression and set ConsistentRead to true.
Attempts:
2 left
💡 Hint

Think about how to reduce the amount of data scanned and speed up the operation.

🔧 Debug
expert
2:00remaining
Diagnosing slow Query performance

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?

AThe Query uses a FilterExpression instead of KeyConditionExpression, causing a syntax error.
BThe Query returns too many items because no sort key condition limits results, causing high latency.
CThe table has no provisioned throughput, so Query is throttled.
DThe partition key is missing from the KeyConditionExpression, causing a full table scan.
Attempts:
2 left
💡 Hint

Consider how the absence of a sort key condition affects the number of items returned.