1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-17017 Explain for query using derived table specified with a table

value constructor shows wrong number of rows

If the specification of a derived table contained a table value constructor
then the optimizer incorrectly estimated the number of rows in the derived
table. This happened because the optimizer did not take into account the
number of rows in the constructor. The wrong estimate could lead to choosing
inefficient execution plans.
This commit is contained in:
Igor Babaev
2018-08-18 22:57:20 -07:00
parent 0dadb96e16
commit a1fd25c22b
9 changed files with 115 additions and 23 deletions

View File

@ -1075,3 +1075,32 @@ DELIMITER ;|
--error ER_EMPTY_ROW_IN_TVC
with t as (values (),()) select 1 from t;
--echo #
--echo # MDEV-17017: TVC in derived table
--echo #
create table t1 (a int);
insert into t1 values (9), (3), (2);
let $q1=
select * from (values (7), (5), (8), (1), (3), (8), (1)) t;
eval $q1;
eval explain $q1;
let $q2=
select * from (values (1,11), (7,77), (3,31), (4,42)) t;
eval $q2;
eval explain $q2;
let $q3=
select * from (values (7), (5), (8), (1) union values (3), (8), (1)) t;
eval $q3;
eval explain $q3;
let $q4=
select * from (values (7), (5), (8), (1) union select * from t1) t;
eval $q4;
eval explain $q4;
drop table t1;