user12530264
user12530264

Reputation:

Is there a difference between DynamoDB Local Secondary Index vs Global Secondary Index if the partition key is the same?

So currently I have a table that is


playerName:String  (Partition)
playerAge:Number   (Sort)
player_str_dex_int_luck:String (Local Secondary Index Sort Key)

I want to add a key to my table player_dex_str_int_luck:String to sort on while keeping playerName as my partition key.

I have to use a GSI for this since you cant create LSI after the table is made. Is there any difference between a GSI and LSI since I'm keeping the partition key of my GSI the same as that of the original table?

Upvotes: 0

Views: 478

Answers (1)

Charles
Charles

Reputation: 23783

LSI - no extra cost, automatically have all attributes of the record. Automatically consistent with the table.

GSI - extra cost, must specify attributes you want in the GSI. For any others, have to read the table. "Updated in an eventually consistent fashion."

However, one benefit of using GSIs instead of LSIs, is that a table without LSI's can have partitions larger than 10GB.

Item Collection Size Limit
The maximum size of any item collection is 10 GB. This limit does not apply to tables without local secondary indexes. Only tables that have one or more local secondary indexes are affected.

Upvotes: 1

Related Questions