Answer the question
In order to leave comments, you need to log in
How to optimize update for a table with nested sets?
Given. MySQL, innoDB, a table with a tree of about 600 thousand records from which a lot is read and from time to time records are added to arbitrary nodes of the tree. Server hardware is quite capable of pulling all this.
To speed up reading, SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED is done.
The problem is updating the table. In itself insert fulfills without problems, apparently. But the subsequent updates for left and right are performed by some prohibitive amount of time. Add requests are taken from the queue.
What can be done to optimize adding records?
ps Probably it is important. The library that works with the tree locks the table at the time of update. If this lock is removed, then deadlocks occur, i.e. nothing works.
Answer the question
In order to leave comments, you need to log in
Try asking in the telegram channel https://t.me/ru_mysql
Somewhere I heard that the update speed can be affected by indexes, if there are a lot of records in the database, then rebuilding indexes is a very expensive operation.
I won’t tell you how to decide, but it’s obvious that you just need to understand why the slowdown occurs and how this can be avoided, for this you need to profil the requests in order to see the numbers and draw the appropriate conclusions, as for me the question is quite difficult ... Without profiling and there is no point in talking about numbers.
There is no universal solution, since each base is unique in its own way.
Write here the solution for the story for posterity.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question