Sanjay
Sanjay

Reputation: 109

How Data get partitioned in table in aws dynamoDb if we have both partition key and secondary key (GSI)

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

Upvotes: 1

Views: 172

Answers (2)

Chris Williams
Chris Williams

Reputation: 35188

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.

Upvotes: 3

TaiT's
TaiT's

Reputation: 3216

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.

Upvotes: 1

Related Questions