mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
ef452e19bf
- Make the range-et-al optimizer produce E(#table records after table condition is applied), - Make the join optimizer use this value, - Add "filtered" column to EXPLAIN EXTENDED to show fraction of records left after table condition is applied - Adjust test results, add comments mysql-test/r/archive_gis.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/auto_increment.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/bdb_gis.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/bench_count_distinct.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/binlog_stm_blackhole.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/case.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/cast.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/compress.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/ctype_collate.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/ctype_cp1250_ch.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/date_formats.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/distinct.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/fulltext.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_compress.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_crypt.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_default.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_encrypt.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_gconcat.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_group.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_if.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_in.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_like.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_math.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_op.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_regexp.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_set.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_str.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_system.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_test.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/func_time.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/gis.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/group_by.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/group_min_max.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/having.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/heap.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/heap_hash.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/index_merge.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/index_merge_innodb.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/index_merge_ror.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/innodb_gis.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/insert_update.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/join.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/join_nested.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/key_diff.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/myisam.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/ndb_gis.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/negation_elimination.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/null.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/olap.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/partition_pruning.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/query_cache.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/row.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/rpl_get_lock.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/rpl_master_pos_wait.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/select.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/ssl.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/ssl_compress.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/subselect.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/type_blob.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/union.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/varbinary.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/variables.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/r/view.result: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/ctype_cp1250_ch.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/func_like.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/group_min_max.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/index_merge_ror.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/index_merge_ror_cpk.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/join.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column mysql-test/t/partition_pruning.test: BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column sql/opt_range.cc: BUG#14940: Make range/index_merge/group-min-max optimizer produce TABLE::quick_condition_rows - estimate of #records that will match the table condition. sql/sql_class.cc: BUG#14940: Add "filtered" column to output of EXPLAIN EXTENDED sql/sql_select.cc: BUG#14940: - Make the join optimizer to use TABLE::quick_condition_rows= = E(#table records after filtering with table condition) - Add "filtered" column to output of EXPLAIN EXTENDED sql/sql_select.h: BUG#14940: Added comments sql/table.h: BUG#14940: Added comments
251 lines
8.5 KiB
Text
251 lines
8.5 KiB
Text
#
|
|
# ROR-index_merge tests.
|
|
#
|
|
--disable_warnings
|
|
drop table if exists t0,t1,t2;
|
|
--enable_warnings
|
|
--disable_query_log
|
|
create table t1
|
|
(
|
|
/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
|
|
st_a int not null default 0,
|
|
swt1a int not null default 0,
|
|
swt2a int not null default 0,
|
|
|
|
st_b int not null default 0,
|
|
swt1b int not null default 0,
|
|
swt2b int not null default 0,
|
|
|
|
/* fields/keys for row retrieval tests */
|
|
key1 int,
|
|
key2 int,
|
|
key3 int,
|
|
key4 int,
|
|
|
|
/* make rows much bigger then keys */
|
|
filler1 char (200),
|
|
filler2 char (200),
|
|
filler3 char (200),
|
|
filler4 char (200),
|
|
filler5 char (200),
|
|
filler6 char (200),
|
|
|
|
/* order of keys is important */
|
|
key sta_swt12a(st_a,swt1a,swt2a),
|
|
key sta_swt1a(st_a,swt1a),
|
|
key sta_swt2a(st_a,swt2a),
|
|
key sta_swt21a(st_a,swt2a,swt1a),
|
|
|
|
key st_a(st_a),
|
|
key stb_swt1a_2b(st_b,swt1b,swt2a),
|
|
key stb_swt1b(st_b,swt1b),
|
|
key st_b(st_b),
|
|
|
|
key(key1),
|
|
key(key2),
|
|
key(key3),
|
|
key(key4)
|
|
) ;
|
|
|
|
# Fill table
|
|
create table t0 as select * from t1;
|
|
let $cnt=1000;
|
|
while ($cnt)
|
|
{
|
|
eval insert into t0 values (1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 'data1', 'data2', 'data3', 'data4', 'data5', 'data6');
|
|
dec $cnt;
|
|
}
|
|
|
|
alter table t1 disable keys;
|
|
let $1=4;
|
|
while ($1)
|
|
{
|
|
let $2=4;
|
|
while ($2)
|
|
{
|
|
let $3=4;
|
|
while ($3)
|
|
{
|
|
eval insert into t1 select $1, $2, $3, $1 ,$2, $3, key1, key2, key3, key4, filler1, filler2, filler3, filler4, filler5, filler6 from t0;
|
|
dec $3;
|
|
}
|
|
dec $2;
|
|
}
|
|
dec $1;
|
|
}
|
|
|
|
# Row retrieval tests
|
|
# -1 is used for values 'out of any range we are using'
|
|
# insert enough rows for index intersection to be used for (key1,key2)
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 100, 100,'key1-key2-key3-key4');
|
|
let $cnt=400;
|
|
while ($cnt)
|
|
{
|
|
eval insert into t1 (key1, key2, key3, key4, filler1) values (100, -1, 100, -1,'key1-key3');
|
|
dec $cnt;
|
|
}
|
|
let $cnt=400;
|
|
while ($cnt)
|
|
{
|
|
eval insert into t1 (key1, key2, key3, key4, filler1) values (-1, 100, -1, 100,'key2-key4');
|
|
dec $cnt;
|
|
}
|
|
alter table t1 enable keys;
|
|
--enable_query_log
|
|
select count(*) from t1;
|
|
|
|
# One row results tests for cases where a single row matches all conditions
|
|
explain select key1,key2 from t1 where key1=100 and key2=100;
|
|
select key1,key2 from t1 where key1=100 and key2=100;
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
|
|
# Several-rows results
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2');
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3');
|
|
|
|
# ROR-intersection, not covering
|
|
explain select key1,key2,filler1 from t1 where key1=100 and key2=100;
|
|
select key1,key2,filler1 from t1 where key1=100 and key2=100;
|
|
|
|
# ROR-intersection, covering
|
|
explain select key1,key2 from t1 where key1=100 and key2=100;
|
|
select key1,key2 from t1 where key1=100 and key2=100;
|
|
|
|
# ROR-union of ROR-intersections
|
|
explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
|
|
# 3-way ROR-intersection
|
|
explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
|
|
select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
|
|
|
|
# ROR-union(ROR-intersection, ROR-range)
|
|
insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101');
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
|
|
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
|
|
|
|
# Run some ROR updates/deletes
|
|
select key1,key2, filler1 from t1 where key1=100 and key2=100;
|
|
update t1 set filler1='to be deleted' where key1=100 and key2=100;
|
|
update t1 set key1=200,key2=200 where key1=100 and key2=100;
|
|
delete from t1 where key1=200 and key2=200;
|
|
select key1,key2,filler1 from t1 where key2=100 and key2=200;
|
|
|
|
# ROR-union(ROR-intersection) with one of ROR-intersection giving empty
|
|
# results
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
|
|
delete from t1 where key3=100 and key4=100;
|
|
|
|
# ROR-union with all ROR-intersections giving empty results
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
|
|
|
# ROR-intersection with empty result
|
|
explain select key1,key2 from t1 where key1=100 and key2=100;
|
|
select key1,key2 from t1 where key1=100 and key2=100;
|
|
|
|
# ROR-union tests with various cases.
|
|
# All scans returning duplicate rows:
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2');
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
|
|
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
|
|
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
|
|
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
|
|
|
|
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
|
|
|
##
|
|
## Optimizer tests
|
|
##
|
|
|
|
# Check that the shortest key is used for ROR-intersection, covering and non-covering.
|
|
explain select * from t1 where st_a=1 and st_b=1;
|
|
explain select st_a,st_b from t1 where st_a=1 and st_b=1;
|
|
|
|
# Check if "ingore index" syntax works
|
|
explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
|
|
|
|
# Do many tests
|
|
# Check that keys that don't improve selectivity are skipped.
|
|
#
|
|
|
|
# Different value on 32 and 64 bit
|
|
--replace_result sta_swt12a sta_swt21a sta_swt12a, sta_swt12a,
|
|
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1;
|
|
|
|
explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1;
|
|
|
|
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
|
|
|
explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b)
|
|
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
|
|
|
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b)
|
|
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
|
|
|
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b)
|
|
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
|
|
|
explain select * from t1
|
|
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
|
|
|
|
explain select * from t1
|
|
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
|
|
|
explain select st_a from t1
|
|
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
|
|
|
explain select st_a from t1
|
|
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
|
|
|
drop table t0,t1;
|
|
|
|
# 'Partially' covered fields test
|
|
|
|
create table t2 (
|
|
a char(10),
|
|
b char(10),
|
|
filler1 char(255),
|
|
filler2 char(255),
|
|
key(a(5)),
|
|
key(b(5))
|
|
);
|
|
|
|
--disable_query_log
|
|
let $1=8;
|
|
while ($1)
|
|
{
|
|
eval insert into t2 values (repeat(char($1+64), 8),repeat(char($1+64), 8),'filler1', 'filler2');
|
|
dec $1;
|
|
}
|
|
insert into t2 select * from t2;
|
|
insert into t2 select * from t2;
|
|
--enable_query_log
|
|
|
|
# The table row buffer is reused. Fill it with rows that don't match.
|
|
select count(a) from t2 where a='BBBBBBBB';
|
|
select count(a) from t2 where b='BBBBBBBB';
|
|
|
|
# BUG#1:
|
|
--replace_result a a_or_b b a_or_b
|
|
explain select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
|
select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
|
select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
|
|
|
|
insert into t2 values ('ab', 'ab', 'uh', 'oh');
|
|
explain select a from t2 where a='ab';
|
|
drop table t2;
|