1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Update matching_candidates_in_table() to treat all conditions similar

Fixed also that the 'with_found_constraint parameter' to
matching_candidates_in_table() is as documented: It is now true only
if there is a reference to a previous table in the WHERE condition for
the current examined table (as it was originally documented)

Changes in test results:
- Filtered was 25% smaller for some queries (expected).
- Some join order changed (probably because the tables had very few rows).
- Some more table scans, probably because there would be fewer returned
  rows.
- Some tests exposes a bug that if there is more filtered rows, then the
  cost for table scan will be higher. This will be fixed in a later commit.
This commit is contained in:
Monty
2021-10-07 20:15:34 +03:00
committed by Sergei Petrunia
parent dc2f0d138d
commit b67144893a
41 changed files with 286 additions and 269 deletions

View File

@ -932,15 +932,15 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be
EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 3 Using where
1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 3 Using where
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 3 75.00 Using where
1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 3 75.00 Using where
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 13
@ -949,8 +949,8 @@ FLUSH TABLES;
EXPLAIN EXTENDED SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 Using index
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 Using index
1 SIMPLE t2 index PRIMARY PRIMARY 8 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join)
1 SIMPLE t3 index PRIMARY PRIMARY 8 NULL 3 75.00 Using where; Using index; Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a2` = `test`.`t1`.`a1` and `test`.`t3`.`a3` = `test`.`t2`.`b2` and `test`.`t3`.`b3` = `test`.`t1`.`b1`
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
@ -960,16 +960,16 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_key 19
Handler_read_next 3
Handler_read_first 2
Handler_read_key 13
Handler_read_next 6
Handler_read_rnd_next 4
# Status of testing query execution:
Variable_name Value
Handler_delete 8
Handler_read_key 19
Handler_read_next 3
Handler_read_key 13
Handler_read_rnd 5
Handler_read_rnd_next 4
Handler_read_rnd_next 28
DROP TABLE t1, t2, t3;
#20