2
votes

Let's say I have a DynamoDB table T with H, R, G, and S as attributes; H being the partition/hash key and R being the range/sort key. Let's say I also have a global secondary index (GSI) that is defined with partition key as G and sort key as S.

When a query is performed using the GSI, giving paginated results, what attributes should be expected in LastEvaluatedKey? I have read the docs but it doesn't give this detail.

2
Why don't you test it out yourself?jellycsc

2 Answers

1
votes

It will return

{
  "G": "foo",
  "S": "bar"
}

In a GSI, that key is not guaranteed to be unique so keep that in mind.

0
votes

Looks like the LastEvaluatedKey would include all four (H, R, G and S) when the query is made on the GSI. The following seems to be the rule:

If we query on GSI, then the LastEvaluatedKey will be the compose of GSI partition key, GSI sort key, primary partition key and primary sort key.

If we query on LSI, then the LastEvaluatedKey will be the compose of LSI sort key, primary partition key and primary sort key.