Sergey Grechin
Sergey Grechin

Reputation: 966

how to use redis for sorting and filtration at the same time?

Imagine: someone has a huge website selling, let's say, T-shirts.

we want to show paginated sorted listings of offers, also with options to filter by parameters, let's say - T-shirt colour.

we use some sort of a traditional data storage (MongoDB, to be precise).

The problem is that MongoDB (as well as other traditional databases) performs poorly when it comes to big offsets. Imagine if a user wants to fetch a page of results somewhere in the middle of this huge list sorted by creation date with some additional filters (for instance - by colour)

There is an article describing this kind of problem: http://openmymind.net/Paging-And-Ranking-With-Large-Offsets-MongoDB-vs-Redis-vs-Postgresql/

Okay now, so we are told that redis is a solution for similar kind of problem. You "just" need to prepare certain data structures and search them instead of your primary storage.

the question is:

What kind of structures and approaches whould you suggest to use in order to solve this with Redis?

Upvotes: 1

Views: 379

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 49972

Sorted Sets, paging through with ZRANGE.

Upvotes: 1

Related Questions