skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. It basically depends on your access patterns. In general, LSI/GSI are helpful in the case where you have access pattern that won’t be efficient costly, and affecting your table availability keeping in mind that this will also cost you some money and then you have to make the cost estimation.

    Other things to consider, LSI can’t be created after the table creation.
    https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LSI.html#LSI.Creating

    Code readability based on your access patterns besides RCU/WCU

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search