0
0
DynamoDBquery~5 mins

Item size limits and considerations in DynamoDB

Choose your learning style9 modes available
Introduction
Knowing item size limits helps you store data efficiently and avoid errors when saving data in DynamoDB.
When designing a table to store user profiles with many details.
When saving large documents or images as items in DynamoDB.
When planning how to split data across multiple items to fit size limits.
When troubleshooting errors related to item size during data insertion.
When optimizing costs by avoiding storing unnecessary large data in items.
Syntax
DynamoDB
Maximum item size = 400 KB (including attribute names and values)
The 400 KB limit includes all attribute names and values in the item.
If your item is larger, you need to split data or store large parts elsewhere.
Examples
This item is small and well under the 400 KB limit.
DynamoDB
-- Example: Storing a small user profile
{
  "UserId": "123",
  "Name": "Alice",
  "Age": 30
}
This item might exceed 400 KB if photos or bio are too large.
DynamoDB
-- Example: Large item with many attributes
{
  "UserId": "456",
  "Photos": ["base64encodedimage1...", "base64encodedimage2..."],
  "Bio": "Very long text..."
}
Sample Program
This example shows a simple item well within the size limit.
DynamoDB
-- Check item size by estimating attribute sizes
-- Example item:
{
  "UserId": "789",
  "Description": "This is a short description."
}

-- This item size is small and allowed in DynamoDB.
OutputSuccess
Important Notes
If your item is close to 400 KB, consider storing large data like images in Amazon S3 and saving only the link in DynamoDB.
Remember that attribute names also count toward the size limit, so keep names short if possible.
Use compression or split data into multiple items if needed to stay within limits.
Summary
DynamoDB items can be up to 400 KB in size including attribute names and values.
Large data should be stored outside DynamoDB with references inside items.
Planning item size helps avoid errors and keeps your database efficient.