Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When and how is a Dynamodb GSI having a Partition Key and Sort Key partitioned?

  1. When and how is a Dynamodb GSI having a Partition Key and Sort Key partitioned?
  2. Is there a maximum size limit on GSI Partitions like table partitions?
  3. If yes then what happens when a uni-cardinal GSI (i.e. GSI having the same partition key across all records) exceeds the storage limit?
like image 216
lalatnayak Avatar asked Oct 06 '18 18:10

lalatnayak


People also ask

What is sort key and partition key in DynamoDB?

Partition key and sort key – Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key. DynamoDB uses the partition key value as input to an internal hash function.

Can we change partition key and sort key in DynamoDB?

Is it possible to change partition key in DynamoDB? No. Once the table is setup, you cannot modify its Key Schema. You can only provision a new table, move data there, and then remove the first table.

What is GSI partition key?

Global secondary index—An index with a partition key and a sort key that can be different from those on the base table. A global secondary index is considered "global" because queries on the index can span all of the data in the base table, across all partitions.

Can GSI have same partition key?

All items with the same partition key are stored together, in sorted order by sort key value. The combination of the partition key and sort key must be unique. It is possible for two items to have the same partition key value, but those two items must have different sort key values.


1 Answers

1) See my answer here https://stackoverflow.com/a/51240423/4985580 for how tables are partitioned. A GSI is essentially just a new table, it is partitioned in the same way as your base table.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.Partitions.html

Global secondary indexes in DynamoDB are also composed of partitions. The data in a GSI is stored separately from the data in its base table, but index partitions behave in much the same way as table partitions.

2) Yes, 10GB

3) That's an interesting question and I don't have the answer. Dynamo accesses the correct partition based on the partition key of the data, so if you fill more than one partition with a single partition key, it seems likely you would have a problem. That said you'd probably need at least 2.5 Million items with the same partition key for this to happen (10GB/4KB). Is this a possible scenario for you?

like image 135
F_SO_K Avatar answered Oct 16 '22 00:10

F_SO_K