Joseph Tey
Joseph Tey

Reputation: 11

DynamoDB Filter Expresson vs GSIs

I am using DynamoDB to store my data. I am creating a dashboard application where users can sort by fields, search by fields, and add multiple filters at once. There will be approx 100 - 1000 entries in the table.

To achieve this search, filter, sort functionality, there are two ways I can achieve this:

  1. Use FilterExpression. A simple solution, however, requires ALL the data to be pulled before filtering (not a 'true' query), requires more server-side processing + FilterExpression often seen as 'bad practice'.

  2. Create GSIs for each field individually. Allows me to search and sort by fields using a true query, reducing server-side processing - can directly get the items I need. The issue with this is adding multiple filters, as it is not possible to use multiple GSIs in a single query call. If I had multiple filters, this approach would require multiple query calls, and manually aggregating / finding common items on client-side.

Would it be acceptable to use FilterExpression in this situation? It would simplify the process so much from a coding / maintenance perspective, but I am unsure if it's good practice. If GSIs are the better option, how would you deal with multiple filters?

Lastly, would there be a better approach, aside from the two options listed above?

Thanks so much in advance!

Upvotes: 1

Views: 479

Answers (1)

Charles
Charles

Reputation: 23783

Honestly, sorting/searching is where DDB falls down..

With the amount of data you're talking about, I'd simply use Aurora.

At scale, assuming you hit the limits of Aurora, you'd be better served by front-ending DDB with Elasticsearch.

Upvotes: 0

Related Questions