I tried to index a date time field in a table with 20 million rows. Majority(99%) of the rows for that column are null. After that, CPU utilization shot up to 100% because of this. I'm not able to find out the exact reason for the same.
1 Answer
As an optimization, InnoDB "delays" the updating of indexes. Probably what happened is that this delayed operation is happening, causing the CPU to spike.
For further info, search for "InnoDB change buffering".
4 Comments
Gargee
I deleted the indexes once CPU spiked up. I need to be sure of the root cause before I create the indexes again. Any pointers for debugging? Any estimate for it's delayed index update to complete?
Rick James
20M rows -- They have to be scanned, a file created and sorted, then written back to disk, etc. Please show us the command you used and the
SHOW CREATE TABLE.Rick James
Minutes / hours. Depends on lots of things -- size of table, setting of
innodb_buffer_pool_size, spinning drives vs SSDs, etcGargee
Algo used:
CREATE INDEX name-index on table-name(column-name) algorithm=inplace