Sample Header Ad - 728x90

Simple Update Join much slower than it should be (MYSQL)

0 votes
1 answer
509 views
This is a simple Update Join that updates only about 100 rows: Update A INNER JOIN B using(id) SET A.active = 1 WHERE A.date > '2020' This takes about 30 seconds to run, despite the fact that: - This query updates the same 100 rows and takes milliseconds to run: Update A SET active = 1 WHERE date > '2020' - The join condition is fast, this query does the same join and takes less than a second SELECT * FROM A INNER JOIN B using(id) WHERE A.date > '2020' - The field active not part of any index - Table A has an index on (id, date), and table B has an index on id. I tried putting the where condition in the join (using on date > '2020') but it didn't help. I'm absolutely stumped why this takes so long. Any help is appreciated.
Asked by Tod (1 rep)
Sep 1, 2020, 05:00 AM
Last activity: Jul 28, 2025, 07:01 AM