0
0
DynamoDBquery~20 mins

BatchGetItem in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
BatchGetItem Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this BatchGetItem request?

Given a DynamoDB table Users with items having UserId as the primary key, consider this BatchGetItem request:

{
  "RequestItems": {
    "Users": {
      "Keys": [
        {"UserId": {"S": "user1"}},
        {"UserId": {"S": "user3"}}
      ]
    }
  }
}

If the table contains these items:

  • UserId: user1, Name: Alice
  • UserId: user2, Name: Bob
  • UserId: user3, Name: Charlie

What will the response contain?

A{"Responses": {"Users": [{"UserId": {"S": "user1"}, "Name": {"S": "Alice"}}, {"UserId": {"S": "user3"}, "Name": {"S": "Charlie"}}]}}
B{"Responses": {"Users": [{"UserId": {"S": "user1"}, "Name": {"S": "Alice"}}]}}
C{"Responses": {"Users": [{"UserId": {"S": "user2"}, "Name": {"S": "Bob"}}]}}
D{"Responses": {"Users": []}}
Attempts:
2 left
💡 Hint

BatchGetItem returns all requested items that exist in the table.

🧠 Conceptual
intermediate
1:30remaining
Which statement about BatchGetItem is true?

Choose the correct statement about DynamoDB's BatchGetItem operation.

ABatchGetItem can only retrieve items from one table per request.
BBatchGetItem can retrieve items from multiple tables in a single request.
CBatchGetItem automatically updates items after retrieval.
DBatchGetItem requires a scan operation to find items.
Attempts:
2 left
💡 Hint

Think about how BatchGetItem handles multiple tables.

📝 Syntax
advanced
2:00remaining
Which BatchGetItem request is syntactically correct?

Identify the syntactically valid BatchGetItem JSON request.

A
{
  "RequestItems": {
    "Products": {
      "Keys": {
        "ProductId": {"S": "p1"}
      }
    }
  }
}
B
{
  "RequestItems": {
    "Products": [
      {"ProductId": {"S": "p1"}},
      {"ProductId": {"S": "p2"}}
    ]
  }
}
C
{
  "RequestItems": {
    "Products": {
      "Key": [
        {"ProductId": {"S": "p1"}}
      ]
    }
  }
}
D
{
  "RequestItems": {
    "Products": {
      "Keys": [
        {"ProductId": {"S": "p1"}},
        {"ProductId": {"S": "p2"}}
      ]
    }
  }
}
Attempts:
2 left
💡 Hint

Check the structure of the Keys attribute.

optimization
advanced
2:00remaining
How to optimize BatchGetItem for large key sets?

You need to retrieve 150 items from a DynamoDB table using BatchGetItem. What is the best approach to avoid request size limits?

AUse Query operation with a filter to retrieve all 150 items in one request.
BSend all 150 keys in a single BatchGetItem request; DynamoDB handles large requests automatically.
CSplit the keys into batches of 100 or fewer and send multiple BatchGetItem requests.
DUse Scan operation instead of BatchGetItem to get all items at once.
Attempts:
2 left
💡 Hint

Remember DynamoDB limits BatchGetItem to 100 items per request.

🔧 Debug
expert
2:30remaining
Why does this BatchGetItem request return unprocessed keys?

Consider this BatchGetItem request to table Orders:

{
  "RequestItems": {
    "Orders": {
      "Keys": [
        {"OrderId": {"S": "o1"}},
        {"OrderId": {"S": "o2"}},
        {"OrderId": {"S": "o3"}}
      ],
      "ConsistentRead": true
    }
  }
}

The response contains UnprocessedKeys with some keys. What is the most likely reason?

AThe request exceeded the provisioned throughput, causing throttling and unprocessed keys.
BThe keys specified do not exist in the table, so they appear as unprocessed.
CConsistentRead cannot be used with BatchGetItem, causing the request to fail partially.
DThe table is in a locked state, preventing any keys from being processed.
Attempts:
2 left
💡 Hint

Think about DynamoDB limits and throttling behavior.