ljaerj
ljaerj

Reputation: 157

DynamoDB Global Secondary Index to increase performance

I am designing an application for tracing call activity.

Each call can be either terminated or activated. An application will query the database every minute to generate a list of activate calls. There can be up to 1000 calls per second.

How should I design my database? Should I have a "Call" table and a global secondary index on "state" attribute that can equal to "activate" or "terminated"

OR

a "Call" table and a global secondary index on "isActive" attribute that is present for active calls only.

Upvotes: 1

Views: 232

Answers (1)

Harshal Bulsara
Harshal Bulsara

Reputation: 8254

Problems you may faced if you go out with schema that you have suggested in the question:

  1. CallList table with 'state' as GSI, this way you will be able to query your GSI and get all the active calls, but eventually it will effect your performance as there is very limited values for partition key (I am assuming you wont be deleting the record either, thus table will grow huge in no time)
  2. CallList table with GSI on isActive, this will have same above problem as most of the rows will have "isActive=False"

My proposed schema:

Keep a separate activeCall table only having an entry of the active calls, this way you don't have to worry about the size of the table or GSI which eventually result in paying less, once call is terminated you can remove the entry from the table.

Upvotes: 2

Related Questions