Please note that I am in no way affiliated with MySQL (AB). I am just a user of their products. Everything you read here, especially my explanations and conclusions are to the best of my knowledge, but there is a chance that they are awfully wrong!
I recently had to investigate the cause for a very long running delete operation in one of our applications. Apparently the time was spent in a single MySQL statement. While looking into the matter I exchanged numerous mails with the MySQL customer support, until I finally came up with a (much) improved version of the query. Along the way I learned some valuable information about MySQL's (or better InnoDB's) transaction levels.
Problem
The general problem looks quite simple:
-
Three tables, let's just call them A (500.000 rows), B (4.000 rows) and C (180.000 rows)
-
B contains detail information for …