R
R
Roman2019-09-02 12:32:47
Database design
Roman, 2019-09-02 12:32:47

How to organize the intersection of a set from one record with sets from other records in Redis?

Question:
- The user has a field in the profile where he can enter some set of _arbitrary_ tags (strings) [say, separated by commas]
- And by clicking on the button, you need to get a list of profiles of other users, sorted by the number of the largest matches of tags in this field (eg both have the tags "apple", "nose" and "pushkin" - 3 matches)
I was advised Redis as the most efficient platform for this task. I have not worked with Redis before, but I found out that the intersection of sets can be obtained simply:
sinter user:1:tags user:2:tags
However, related questions remain a mystery to me due to inexperience
: records? Those.

sinter user:1:tags user:2:tags
sinter user:1:tags user:3:tags
sinter user:1:tags user:4:tags
...
sinter user:1:tags user:n:tags

Or is there a more efficient way?
2. How and where to add intermediate results? What do you advise?
3. Is it worth storing the rest of the user profile data in Redis, or is it better to put them "as usual" in MySQL?
4. If the answer to item 1 is positive, i.e. I have to do a LOT of database queries in a loop, maybe it's better to consider other options besides Redis? For example, stored procedures in MySQL or something else? I want to get such a selection takes at least seconds, on a database with a million records.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question