Search code examples
amazon-web-servicesamazon-dynamodb

L/GSI vs sortkey begins_with()?


Is there any advantage with going L/GSI route that is a subset of sort key to prevent using sort key begins_with? example: Sort Key is a composite of field a and b and c. There will be a frequent query over known(a)-known(b). Is there an efficiency/cost advantage in putting L/GSI over a field a composite field of a and b?


Solution

  • Begins-with is extremely efficient. If you can do a Query with that to retrieve a range of items in one go, you’re in good shape. No need for a secondary index to try to optimize further.