1

I am new to AWS, while reading the DynamoDB docs I came to know that we can have GSI and partition key on same table.

How does DynamoDB keep the data in the same table on the basis of to keys(partitioned and secondary).

Thanks

2 Answers 2

3

DynamoDB actually replicates data changes across to the GSI, in fact AWS recommends the write capacity is equal or higher on a GSI than that of the base table.

To avoid potential throttling, the provisioned write capacity for a global secondary index should be equal or greater than the write capacity of the base table because new updates write to both the base table and global secondary index.

The GSI could be stored on completely different infrastructure than that of the base table.

A global secondary index is stored in its own partition space away from the base table and scales separately from the base table.

Sign up to request clarification or add additional context in comments.

Comments

1

Your main table is composed at least of a partition key and an optional sortkey. When you add a GSI, it's actually a replication of the main table using the GSI as the new partition key.

When you update your main table, the changes are propagated to the GSI. There is always a short propagation delay between a write to the parent table and the time when the written data appears in the index. In other words, your applications should take into account that the global secondary index replica is only eventually consistent with the parent table.

3 Comments

What if we have multiple GSI in single table, then it would create multiple replicas of main table using GSI??
Right, each GSI's becoming a new partition key. But be aware about the consistency.
Think of a GSI as it's own table that is being populated from the base table. For the consistency issue, that is why LSIs exist, but then you are limited to having the same partition key, but you can have a different sort key than the base table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.