Dynamodb Global Secondary Index
The local and global index models extend the basic indexing functionality provided by dynamodb.
Dynamodb global secondary index. Lets consider some use cases for each model. A local secondary index is local in the sense that every partition of a local secondary index is scoped. Local secondary indexes are always queried with respect to the table s hash key combined with the range key specified for that index. Think of a global secondary index as a separate dynamodb table that contains a subset of attributes from the source table.
Global gsi vs local secondary indexes lsi aws dynamodb supports two types of indexes. Creating a global secondary index. The type of index to be created either a global secondary index or a local secondary index. However you may also add a global secondary index after a table is already created.
A global secondary index is considered global because queries on the index can span all of the data in a table across all partitions. Global secondary index gsi and local secondary index lsi. It is deemed global because queries on the index can. For global secondary index queries dynamodb calculates the provisioned read activity in the same way as it does for queries against tables.
The only difference is that the calculation is based on the sizes of the index entries rather than the size of the item in the base table. Dynamodb will backfill the global secondary index based on the existing data in the table. The naming rules for indexes are the same as those for tables as listed in service account and table quotas in amazon dynamodb. It also contains an alternate primary key to support query operations.
Like local secondary indexes you may specify a global secondary index when you initially create a table. Local secondary index an index that has the same hash key as the table but a different range key.