A global secondary index is an automatically maintained projection of a DynamoDB table that supports efficient queries through an additional key. Its partition key can differ from the parent table's partition key, and its key need not be unique. section 12.4.3 section 12.15
Use an index when the table's primary key cannot answer a recurring access pattern. In the todo-task example, category becomes the index partition key and tid becomes its sort key, enabling tasks to be queried by category. section 12.4.2 section 12.4.3
Plan and operate a global secondary index with these constraints:
- Wait for creation to finish and inspect its status with describe-table before relying on the index. section 12.4.4
- Budget for index storage and additional write capacity, because table writes update the index asynchronously. section 12.4.3
Query tasks by category
Create category-index on todo-task with category as the partition key, tid as the sort key, and an ALL projection. Query it with task-la shopping to retrieve shopping tasks for John and Emma. section 12.4.4
