0

I'm designing a DynamoDB single table where I need to frequently update the access pattern values.

I have a high demand access pattern > get details by status. So either I can access this using sort key = status or using gsi = status.

Since this access pattern is using high in my scenario, I initially decided to use the sort key = status in the base table itself.

But I need to update this status(sort key) frequently. I know that base table primary key (PK+SK) cannot modify. So for this approach I need to delete item and put as a new record with modified sort key.

Or Alternatively I can use it in Global Secondary Index (GSI) and update the item. But then the high access pattern will be use GSI. (and i think it will delete and add as a new record in gsi table behind the scene also.)

Considering both cost-effectiveness and best practices, which approach would be more advisable in this scenario? Any insights or recommendations would be greatly appreciated.

Thank you.

1 Answer 1

0

There's no difference in cost, either way you have to pay for a delete then a put.

Using a GSI you will offload the logic to DynamoDB which simplifies how you interact with DynamoDB. But then you must also pay for extra storage, which is the only cost differentiator.

Using the base table, your client will need to ensure that you delete and put the item correctly, and ensure you don't fail on either one, which can be difficult. You could use transactions to achieve this on an atomic way, but now you've doubled your write costs compared to the GSI method.

The choice is yours.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.