I'm trying to explain my problem by examples. I've a long running statement like
UPDATE <table_A>
INNER JOIN <table_B> ON [...]
LEFT JOIN <table_C> ON [...]
LEFT JOIN <table_D> ON [...]
LEFT JOIN <table_E> ON [...]
SET <table_A>.<col_A>=X
WHERE <table_A>.<col_A>=Y AND COALESCE(<table_C>.<id>,<table_D>.<id>,<table_E>.<id> IS NULL
This statement runs on big tables (two of them contain 7+ million rows per table). The update runs 3-5 minutes. In another sessions there is done in high concurrency
UPDATE <table_C> SET <col_A>=Z WHERE <id> IN ([...])
or
DELETE FROM <table_C> WHERE <id> IN ([...])
When the big UPDATE
runs, then these concurrent UPDATE
and DELETES
die with lockwait timeout or deadlocks after one or two minutes. All JOIN
columns are indexed (standard indexes).
I've already tried to do
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
[BIG UPDATE];
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
but that doesn't help. Data consistency on <table_A>
is not so important (it's no problem if it contains rows which do not exist in <table_C>
...<table_E>
anymore). The most important is, that the small UPDATE
/DELETE
s on <table_C>
...<table_E>
are being processed.