Answer the question
In order to leave comments, you need to log in
How to share a large table of private messages?
Yes:
There is a table of personal messages, the number of entries is approaching 100M :( and the speed of working with this table is decreasing and decreasing. The table is often written and often read.
Messages:
msg_id - auto_increment
from_id - sender user ID
to_id - recipient user ID
subj - subject
date - creation time
status - new, read, replied
Answer the question
In order to leave comments, you need to log in
Wow, well, you tightened up with scaling! I will share a link to the Pinterest architecture presentation , in which they talk about how they overcame this problem and share code examples. Perhaps it will help.
Automatic (user click) archiving to arch_msg table by date? With the same fields and archiving date entry?
As for sharding, I advise you to watch the video univertv.ru/video/informatika/programmirovanie/ruby_on_rails_moscow/rails_do_scale/ there are rails, but sharding is also affected well.
It is necessary to stomp on how the selects are spinning on this table. Based on the assumption that most often the client needs to show all his messages, it is logical to do hash partitioning by the recipient ID. The number of partitions to pick up empirically. If the muscle supports double partitioning, the second level of partitions can be sliced by date. The most distant partitions can be dropped or transferred to the archive.
For some reason, there is a feeling that you do not have indexes on the table.
100Mb, while 99.99% of your selections (if admins do not monitor the PM by keywords) then the selection by from_id to_id, if there are indices on these fields, everything should fly at 100mb, then everything, even if you have users by 10% personals generating.
In extreme cases, you can cut the table into 2 parts. Load auto_id into one, from_id to_id, into another auto_id and everything else.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question