1

I know there are a bunch of questions like this, but some don't work with MySQL and others seem to run infinitely until I kill them manually using the processlist, including the one below.

-- both tables have around 3.5 million rows
UPDATE A a
INNER JOIN B b ON a.indexed = b.indexed
SET a.B_id = b.id;

I guess where I deviated from the other questions is that I don't join on the primary keys (I'm updating those instead), but I don't think that should matter. And around 3.5 million rows (both tables) shouldn't spill over to disk unless perhaps I'm accidentally running a Cartesian product.

So what am I doing wrong?

/edit: query finally finished on the server after about 40 minutes.

Benny Bottema
  • 11,111
  • 10
  • 71
  • 96
  • "perhaps I'm accidentally running a Cartesian product." Don't worry your not running a Cartesian product.. You might gain better performance when you make a covering index on B(indexed, id) – Raymond Nijland Nov 13 '17 at 15:45

0 Answers0