mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-28540 Deprecate and ignore the parameter innodb_prefix_index_cluster_optimization
The parameter innodb_prefix_index_cluster_optimization used to enable an
optimization that was added in cb37c55768
and was disabled by default.
We will unconditionally enable the extension and mark the parameter
as deprecated.
Related to this, the counters
Innodb_secondary_index_triggered_cluster_reads and
Innodb_secondary_index_triggered_cluster_reads_avoided
allowed to determine the usefulness of this optimization.
Now that the configuration parameter is disabled, the counters
do not serve any useful purpose and can be removed.
row_search_with_covering_prefix(): Fix a bug that caused an
incorrect result to be returned.
This commit is contained in:
@ -1,8 +1,3 @@
|
||||
SET @save_opt= @@GLOBAL.innodb_prefix_index_cluster_optimization;
|
||||
set global innodb_prefix_index_cluster_optimization = ON;
|
||||
show variables like 'innodb_prefix_index_cluster_optimization';
|
||||
Variable_name Value
|
||||
innodb_prefix_index_cluster_optimization ON
|
||||
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
|
||||
SET GLOBAL innodb_stats_persistent = OFF;
|
||||
# Create a table with a large varchar field that we index the prefix
|
||||
@ -31,110 +26,39 @@ id fake_id bigfield
|
||||
32 1032 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
33 1033 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
128 1128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
|
||||
# Baseline sanity check: 0, 0.
|
||||
select "no-op query";
|
||||
no-op query
|
||||
no-op query
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible for optimization.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('d', 31);
|
||||
id bigfield
|
||||
31 ddddddddddddddddddddddddddddddd
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Eligible for optimization, access via fake_id only.
|
||||
select id, bigfield from prefixinno where fake_id = 1031;
|
||||
id bigfield
|
||||
31 ddddddddddddddddddddddddddddddd
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible for optimization, access via fake_id of big row.
|
||||
select id, bigfield from prefixinno where fake_id = 1033;
|
||||
id bigfield
|
||||
33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible for optimization.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('x', 32);
|
||||
id bigfield
|
||||
32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible for optimization.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('y', 33);
|
||||
id bigfield
|
||||
33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible, should not increment lookup counter.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('b', 8);
|
||||
id bigfield
|
||||
8 bbbbbbbb
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Eligible, should not increment lookup counter.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('c', 24);
|
||||
id bigfield
|
||||
24 cccccccccccccccccccccccc
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Should increment lookup counter.
|
||||
select id, bigfield from prefixinno where bigfield = repeat('z', 128);
|
||||
id bigfield
|
||||
128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Disable optimization, confirm we still increment counter.
|
||||
set global innodb_prefix_index_cluster_optimization = OFF;
|
||||
select id, bigfield from prefixinno where fake_id = 1033;
|
||||
id bigfield
|
||||
33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
drop table prefixinno;
|
||||
# Multi-byte handling case
|
||||
set global innodb_prefix_index_cluster_optimization = ON;
|
||||
SET NAMES utf8mb4;
|
||||
CREATE TABLE t1(
|
||||
f1 varchar(10) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_BIN,
|
||||
@ -146,113 +70,47 @@ INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢');
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a';
|
||||
f1
|
||||
a
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%';
|
||||
f1
|
||||
cccc
|
||||
cčc
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
3
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až';
|
||||
f1
|
||||
až
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழ்';
|
||||
f1
|
||||
தமிழ்
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggᵷ%';
|
||||
f1
|
||||
ggᵷg
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%';
|
||||
f1
|
||||
😊me
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢';
|
||||
f1
|
||||
ls¢
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '¢¢%';
|
||||
f1
|
||||
¢¢
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🐱🌑%';
|
||||
f1
|
||||
🐱🌑
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%';
|
||||
f1
|
||||
🌑
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
2
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%';
|
||||
f1
|
||||
🌒
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
2
|
||||
DROP TABLE t1;
|
||||
# Multi-byte with minimum character length > 1 bytes
|
||||
CREATE TABLE t1(
|
||||
@ -265,113 +123,47 @@ INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢');
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a';
|
||||
f1
|
||||
a
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%';
|
||||
f1
|
||||
cccc
|
||||
cčc
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
3
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až';
|
||||
f1
|
||||
až
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழ்';
|
||||
f1
|
||||
தமிழ்
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggᵷ%';
|
||||
f1
|
||||
ggᵷg
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
2
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%';
|
||||
f1
|
||||
😊me
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Not eligible - record length longer than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢';
|
||||
f1
|
||||
ls¢
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX(`f1`) WHERE f1 like '¢¢%';
|
||||
f1
|
||||
¢¢
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Eligible - record length shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🐱🌑%';
|
||||
f1
|
||||
🐱🌑
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
1
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Eligible - record length is shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%';
|
||||
f1
|
||||
🌑
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
2
|
||||
# Eligible - record length is shorter than prefix length
|
||||
SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%';
|
||||
f1
|
||||
🌒
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
2
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(
|
||||
col1 INT,
|
||||
@ -383,22 +175,10 @@ INSERT INTO t1(col1) VALUES(1);
|
||||
SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 is NULL;
|
||||
col1
|
||||
1
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
0
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
1
|
||||
# Not eligible - record length longer than prefix index
|
||||
SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 like 'test1%';
|
||||
col1
|
||||
3
|
||||
select @cluster_lookups;
|
||||
@cluster_lookups
|
||||
2
|
||||
select @cluster_lookups_avoided;
|
||||
@cluster_lookups_avoided
|
||||
0
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-20464 Division by 0 in row_search_with_covering_prefix()
|
||||
@ -443,18 +223,10 @@ INSERT INTO wp_blogs (domain, path) VALUES
|
||||
('domain.no', '/fondsinvesteringer/'), ('domain.no', '/'),
|
||||
('foo', 'bar'), ('bar', 'foo'), ('foo', 'foo'), ('bar', 'bar'),
|
||||
('foo', 'foobar'), ('bar', 'foobar'), ('foobar', 'foobar');
|
||||
SET GLOBAL innodb_prefix_index_cluster_optimization=off;
|
||||
SELECT blog_id FROM wp_blogs WHERE domain IN ('domain.no')
|
||||
AND path IN ( '/fondsinvesteringer/', '/' );
|
||||
blog_id
|
||||
2
|
||||
1
|
||||
SET GLOBAL innodb_prefix_index_cluster_optimization=on;
|
||||
SELECT blog_id FROM wp_blogs WHERE domain IN ('domain.no')
|
||||
AND path IN ( '/fondsinvesteringer/', '/' );
|
||||
blog_id
|
||||
2
|
||||
1
|
||||
DROP TABLE wp_blogs;
|
||||
SET GLOBAL innodb_prefix_index_cluster_optimization = @save_opt;
|
||||
SET GLOBAL innodb_stats_persistent = @save_innodb_stats_persistent;
|
||||
|
Reference in New Issue
Block a user