wlad is says that on Windows, testing with 16 to 64 concurrent users, with the thread pool enabled, the AHI is not helping much. This seems to be in line with a benchmark by Mark Callaghan from 5 years ago.
Because of the above mentioned MySQL 5.7 change, I tried a similar INSERT benchmark:
--source include/have_innodb.inc
|
--source include/have_sequence.inc
|
CREATE TABLE t1 (a BIGINT UNSIGNED PRIMARY KEY, b CHAR(255) NOT NULL DEFAULT '', c CHAR(255) NOT NULL DEFAULT '') ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
INSERT INTO t1 (a) SELECT * FROM seq_1_to_10000000;
|
DROP TABLE t1;
|
invoked like this:
for ahi in 1 0 1 0 1 0
|
do ./mtr --mysqld=--innodb-log-file-size=100m --mysqld=--innodb-adaptive-hash-index=$ahi --mysqld=--skip-innodb-buffer-pool-dump-at-shutdown --mysqld=--innodb-buffer-pool-size=128m --mysqld=--innodb-page-size=4k main.ahi
|
done
|
There was some variation in the execution times, but the adaptive hash index was not systematically faster. I also rebuilt the server without the adaptive hash index altogether:
cmake -DWITH_INNODB_AHI=OFF
|
make -j$(nproc)
|
The execution time remained similar.
I believe that corruption reports, such as MDEV-18815, are a strong enough reason to disable the adaptive hash index by default. Those corruptions could have started to occur when MySQL 5.6 and MariaDB Server 10.0 introduced atomic memory access for the field buf_fix_count. That could have broken the special logic around buf_fix_count==0. I can remember some cases of AHI corruption during the development MySQL 5.6 already.
Theoretically, disabling the adaptive hash index could cause some loss of performance in a special case. Here is some analysis. But is this worth the added code complexity and hard-to-chase bugs?
For the record, there was this change in MySQL 5.7:
A more appropriate fix (which I was not allowed to consider at that time) would have been to investigate why the sorted inserts (into a table that did not have any secondary indexes) end up performing AHI lookups at all, and to fix that. InnoDB should remember and take advantage of the last insert position, both in the cursor (table handle) and in each index page.
It could be useful to test the described scenario (unfortunately no more details are available) with both values of innodb_adaptive_hash_index. It could have been a BIGINT UNSIGNED key (8 bytes). Without the above patch in 5.7 (that code was removed by me earlier during the 5.7 development), the AHI would not be used much, or at all.