Creating a DynamoDB table in AWS - Performance & Efficiency
When creating a DynamoDB table, it is important to understand how the time to complete the creation grows as we add more tables.
We want to know how the number of tables affects the time it takes to create a new one.
Analyze the time complexity of the following operation sequence.
# Create a DynamoDB table
aws dynamodb create-table \
--table-name MyTable \
--attribute-definitions AttributeName=Id,AttributeType=S \
--key-schema AttributeName=Id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
This operation creates a single DynamoDB table with a primary key and provisioned throughput settings.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: The API call to create a DynamoDB table.
- How many times: Once per table creation request.
Each time you create a new table, you make one API call that provisions that table.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of API calls grows directly with the number of tables created.
Time Complexity: O(n)
This means the time to create tables grows linearly with how many tables you want to create.
[X] Wrong: "Creating multiple tables happens all at once and takes the same time as creating one."
[OK] Correct: Each table creation is a separate operation that takes time, so more tables mean more total time.
Understanding how resource creation scales helps you design systems that handle growth smoothly and predict delays when provisioning resources.
"What if we changed to creating tables in parallel instead of one after another? How would the time complexity change?"