I think you have some misunderstandings. When you insert a row, InnoDB doesn't rebuild the whole index. It just adds an entry to the existing index. It would be incredibly bad for performance if it had to rebuild the index on a large table after every INSERT.
Another misunderstanding is about the deferred index update. The index is still usable during this time. InnoDB knows how to check entries that are in the change buffer as well as the index. If a query reads a value from the change buffer, this causes it to be merged into the index immediately. If a query reads other values that are already merged into the index, the index helps that query.
You might be trying to solve a problem that does not exist.
As for the question you asked, how to tell if the index is fully merged, it's tricky to do this. You can query to see how much of the buffer pool is allocated to the change buffer (this is documented on this manual page: https://dev.mysql.com/doc/refman/8.0/en/innodb-change-buffer.html)
SELECT (SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE PAGE_TYPE LIKE 'IBUF%') AS change_buffer_pages,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE) AS total_pages,
(SELECT ((change_buffer_pages/total_pages)*100))
AS change_buffer_page_percentage;
+---------------------+-------------+-------------------------------+
| change_buffer_pages | total_pages | change_buffer_page_percentage |
+---------------------+-------------+-------------------------------+
| 2064 | 8191 | 25.1984 |
+---------------------+-------------+-------------------------------+
This shows after I inserted a couple of million rows into a test table, about 25% of my buffer pool is occupied by change buffer content waiting to be merged. But it does not tell me which table or index, so it could be changes for other table(s) that are accounting for this.
Over time, the change buffer pages will grow and shrink, as index changes are merged and other INSERT/UPDATE/DELETE traffic comes in.
innodb_ibuf_accel_rate
. Anyhow, disablingchange buffer
will reduce the speed of largeINSERT
s. It is good to have the change buffer, but I want to flush it right after the query.innodb_ibuf_max_size
is nowinnodb_change_buffer_max_size
, as InnoDB changed the terminology, thoughIbuf
is still used in STATUS.innodb_max_dirty_pages_pct
force the flushing?