Member-only story
DynamoDB’s New Feature Now Supports Multi-Attribute Keys For GSIs
Here’s how to make the most of this new feature and some data modeling tips on it
Amazon DynamoDB has just released one of the most impactful updates in recent years: native support for multi-attribute composite keys in Global Secondary Indexes (GSIs).
For architects, serverless developers, and AWS engineers, this is a big deal.
Until now, you had to manually concatenate multiple values into synthetic keys.
e.g. user#123#region#eu#status#active
in order to support complex query patterns. This approach works, but it requires overhead, having to maintain multiple values in one key, and forces everything into a string type.
Now, you can define up to 4 attributes for the GSI partition key and up to 4 attributes for the sort key, using native attribute types directly. This results in cleaner data models, better type safety, and far more flexible querying.
Let’s break it down.
Real-World Example: Multi-Tenant CRM System
Imagine you’re building a CRM app where users belong to organizations, and you want to fetch customers based on: