I have a file with about 40 CREATE INDEX statements in it. I fed this file to my production database some time ago and it’s currently running the commands.
Not too long ago I accidentally ran a couple slow queries on my production database and now I’m afraid I may have gummed up the works. Normally when I run an unacceptably slow query I restart MySQL, but I’m not sure I want to do that because I don’t know if it’s safe to do that while MySQL is running these CREATE INDEX statements.
For more context, if I run select * from information_schema.statistics where index_name like 'index_%', I usually see a new index show up every few minutes, but it seems to have been stuck at 14 indexes for some time.
Should I restart the server or not?
There is no problem. Use a
show create table FOOto see what indexes you are missing and apply them. In the end you can do an optimize table to rebuild all indexes.Note that if these 40
create indexstatements are on the same table then you should definitelly rewrite this (and any further) query into a single one. Otherwise you are waiting 39 times more than you could.