Hi, there is a task: to implement a system of likes. The user can like the other user, and only one. There is a website with 25 thousand + users. Attendance 6-7 thousand unik per day. During authorization, the user is cached in a memkesh and all his data is taken from there. There is an idea, when authorizing, to cache those likes that the user put, so as not to get into the database once again. Or do it in the forehead, a table with two fields (the id of the user who puts the like and the id of the person who receives it). Actually I would like to see your opinions on this subject, interesting and beautiful decisions.

  • Maybe just a limit of likes and no matter whom the user specifically liked? The base is used only when you need to know who exactly the user liked. - igumnov
  • As you said - a table with two fields. Only in addition the primary key on these TWO FIELDS. - Stanislav Yelkov

2 answers 2

You can create a VIEW for these likes. There will just be 2 fields and no primary keys. After a couple of dozens of queries, the database will work faster.

It is very important for the database to have a good disk. When working with Magento, he experienced the joy of switching from a regular physical disk to SSD)

    The query on the cluster key (and it will be such) works very, very fast :).

    Obviously writing to likes is much less common than reading. This means that the database server will effectively cache the data itself. You just need to give it enough memory and set configuration parameters.

    It’s not a fact that giving some resources specifically for the cache of likes you gain in overall performance. Optimization is a priority issue.

    • Looks like you are two years late) - user26699
    • You are right))) For some reason this question appeared in the tape. It never occurred to me to watch his date. - artoodetoo