I’m trying to test the feature documented here:
[URL=“Prefix Index Queries Optimization — Percona Server 8.0 Documentation”]https://www.percona.com/doc/percona-...imization.html[/URL]
But in the test cases I’ve made, it simply doesn’t apply:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.16-7 |
+-----------+
1 row in set (0.00 sec)
mysql> CREATE TABLE product (
-> id INT UNSIGNED AUTO_INCREMENT,
-> code VARCHAR(20),
-> quantity INT UNSIGNED,
-> PRIMARY KEY (id),
-> INDEX idx_code_3_quantity (code(3), quantity)
-> ) ENGINE InnoDB;
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO product (code, quantity) VALUES
-> ('ABC-something', 3)
-> , ('ABC-nothing', 0)
-> , ('ABC-anything', 1)
-> , ('ZZZ-whoever', 5)
-> , ('KKK-wherever', 3)
-> ;
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> SHOW GLOBAL STATUS LIKE 'Innodb_secondary_index_triggered_cluster_reads%';
+--------------------------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------------------------+-------+
| Innodb_secondary_index_triggered_cluster_reads | 5228 |
| Innodb_secondary_index_triggered_cluster_reads_avo ided | 0 |
+--------------------------------------------------------+-------+
2 rows in set (0.00 sec)
mysql> SELECT quantity
-> FROM product
-> WHERE code LIKE 'ABC%' AND quantity > 0
-> ;
+----------+
| quantity |
+----------+
| 1 |
| 3 |
+----------+
2 rows in set (0.00 sec)
mysql> SHOW GLOBAL STATUS LIKE 'Innodb_secondary_index_triggered_cluster_reads%';
+--------------------------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------------------------+-------+
| Innodb_secondary_index_triggered_cluster_reads | 5231 |
| Innodb_secondary_index_triggered_cluster_reads_avo ided | 0 |
+--------------------------------------------------------+-------+
2 rows in set (0.00 sec)
It could be a bug but, since I wasn’t able to find a single case where this feature works, I assume that I’m missing something instead. Can anyone from Percona explain in which cases it works, and why it doesn’t work in this test?