CCCC
CCCC

Reputation: 6461

Dynamodb - how to pick appropriate GSI and LSI

There are 5 columns in my Table "Banners".

id(string) | createdAt(Date) | caption(string) | isActive(binary) | order(Int)

For now, id is the partition key and primary key.

In the future, I might want to do something like getting all banners with isActive =1 and sorted by order.

As far as I understand, GSI is the another option for partition key, LSI is like the second sort key with unchanged partition key in the table.

Should isActive be GSI and order be LSI?

Upvotes: 1

Views: 428

Answers (1)

jellycsc
jellycsc

Reputation: 12259

Here is my rule of thumb when it comes to the LSI: only use it when you

  1. need strong read consistency in the secondary index
  2. want to save provisioned RCU and WCU of the secondary index

Otherwise, use the GSI without any hesitation.

Upvotes: 1

Related Questions