Table capacity modes (on-demand vs provisioned) in DynamoDB - Performance Comparison
When using DynamoDB, how fast your requests run depends on the table's capacity mode.
We want to understand how the choice between on-demand and provisioned modes affects request speed as data grows.
Analyze the time complexity of reading an item from a DynamoDB table in different capacity modes.
// Read item from DynamoDB table
const params = {
TableName: "MyTable",
Key: { "id": "123" }
};
const result = await dynamodb.getItem(params).promise();
return result.Item;
This code fetches one item by its key from a DynamoDB table.
Look for repeated steps that affect speed.
- Primary operation: Single key lookup in the table.
- How many times: Once per request; no loops or recursion here.
As the table grows, how does the time to get one item change?
| Input Size (n) | Approx. Operations |
|---|---|
| 10 items | 1 lookup operation |
| 1,000 items | 1 lookup operation |
| 1,000,000 items | 1 lookup operation |
Pattern observation: The time to get one item stays about the same no matter how big the table is.
Time Complexity: O(1)
This means fetching one item takes about the same time regardless of table size.
[X] Wrong: "On-demand mode is slower because it handles more requests automatically."
[OK] Correct: Both on-demand and provisioned modes use the same fast key lookup; the difference is in how capacity is managed, not speed per request.
Knowing how DynamoDB handles capacity helps you explain performance choices clearly and shows you understand cloud database behavior.
"What if we changed the query to scan the whole table instead of a key lookup? How would the time complexity change?"