2017-03-03, 19:11
(2017-03-03, 18:30)DaveBlake Wrote: You may note I have sneaked into my previous post and edited the SQL. No need to do the old form delete, I know it will lock. And of course you have not got 371k of artists, that is just the size of the tmp_delartists table including lots of duplicates, so I am curious how many you have got. I also may have a fix.
Cut and paste that SQL!
First line has a typo (it is artist, not artists):
Code:
MariaDB [MyMusic60]> SELECT COUNT(1) as artistcount FROM artists;
ERROR 1146 (42S02): Table 'MyMusic60.artists' doesn't exist
And index doesn't work
Code:
MariaDB [MyMusic60]> CREATE INDEX ts_id1 ON tmp_delartists (idSong);
ERROR 1072 (42000): Key column 'idSong' doesn't exist in table
Code:
MariaDB [MyMusic60]> SELECT COUNT(1) as toremove FROM artist WHERE idArtist NOT IN (SELECT idArtist FROM tmp_delartists);
+----------+
| toremove |
+----------+
| 4 |
+----------+
1 row in set (4.03 sec)
MariaDB [MyMusic60]> DELETE FROM artist WHERE idArtist NOT IN (SELECT idArtist FROM tmp_delartists);
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction