0
0
DynamoDBquery~5 mins

Transaction limits in DynamoDB

Choose your learning style9 modes available
Introduction
Transaction limits help keep your database safe and fast by controlling how many operations you can do at once.
When you want to update multiple items together and need to know the maximum number allowed.
When you want to avoid errors by not exceeding the allowed number of operations in a single transaction.
When planning your app to handle many changes at once but within safe limits.
When you want to understand how many items you can read or write in one transaction.
When debugging errors related to too many operations in a transaction.
Syntax
DynamoDB
No direct syntax to set limits; limits are fixed by DynamoDB service.

Limits include:
- Maximum 100 unique items per transaction
- Maximum 4 MB total size per transaction
- Maximum 25 operations per TransactWriteItems
- Maximum 25 operations per TransactGetItems
DynamoDB enforces these limits automatically; you cannot change them.
If you exceed limits, DynamoDB returns an error and the transaction fails.
Examples
This is allowed because it is under the 25 operation limit.
DynamoDB
TransactWriteItems with 3 Put operations and 2 Update operations (total 5 operations)
This is allowed because it is under the 25 operation limit.
DynamoDB
TransactGetItems with 20 Get operations
This will fail because it exceeds the 25 operation limit.
DynamoDB
TransactWriteItems with 26 Put operations
Sample Program
This transaction writes 3 operations (Put, Update, Delete) which is within the 25 operation limit.
DynamoDB
aws dynamodb transact-write-items --transact-items '[
  {"Put": {"TableName": "Books", "Item": {"BookId": {"S": "1"}, "Title": {"S": "Book One"}}}},
  {"Update": {"TableName": "Books", "Key": {"BookId": {"S": "2"}}, "UpdateExpression": "SET Title = :t", "ExpressionAttributeValues": {":t": {"S": "Updated Title"}}}},
  {"Delete": {"TableName": "Books", "Key": {"BookId": {"S": "3"}}}}
]'
OutputSuccess
Important Notes
Keep your transactions small to avoid hitting limits and failing.
If you need to update many items, consider splitting into multiple transactions.
Check error messages carefully; they will tell you if you hit a transaction limit.
Summary
DynamoDB transactions have fixed limits on number of operations and size.
TransactWriteItems allows up to 25 operations; TransactGetItems allows up to 25.
Exceeding limits causes transaction failure; plan your operations accordingly.