25 changed files with 1219 additions and 34 deletions
-
13mysql-test/r/mysqld--help.result
-
114mysql-test/r/selectivity.result
-
119mysql-test/r/selectivity_innodb.result
-
101mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result
-
138mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test
-
65mysql-test/t/selectivity.test
-
12mysql-test/t/selectivity_innodb.test
-
56sql/field.cc
-
27sql/field.h
-
20sql/item_cmpfunc.cc
-
2sql/item_cmpfunc.h
-
219sql/opt_range.cc
-
2sql/opt_range.h
-
6sql/opt_range_mrr.cc
-
2sql/opt_subselect.cc
-
1sql/opt_subselect.h
-
1sql/sql_class.h
-
1sql/sql_priv.h
-
268sql/sql_select.cc
-
6sql/sql_select.h
-
49sql/sql_statistics.cc
-
6sql/sql_statistics.h
-
16sql/sys_vars.cc
-
6sql/table.cc
-
3sql/table.h
@ -0,0 +1,114 @@ |
|||
select @@global.use_stat_tables; |
|||
@@global.use_stat_tables |
|||
COMPLEMENTARY |
|||
select @@session.use_stat_tables; |
|||
@@session.use_stat_tables |
|||
COMPLEMENTARY |
|||
set @save_use_stat_tables=@@use_stat_tables; |
|||
set use_stat_tables='preferably'; |
|||
DROP DATABASE IF EXISTS dbt3_s001; |
|||
CREATE DATABASE dbt3_s001; |
|||
use dbt3_s001; |
|||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; |
|||
EXPLAIN EXTENDED select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
id select_type table type possible_keys key key_len ref rows filtered Extra |
|||
1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort |
|||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 |
|||
1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where |
|||
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where |
|||
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where |
|||
4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where |
|||
Warnings: |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10 |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
s_name s_address |
|||
Supplier#000000010 Saygah3gYWMp72i PY |
|||
set optimizer_use_condition_selectivity=3; |
|||
EXPLAIN EXTENDED select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
id select_type table type possible_keys key key_len ref rows filtered Extra |
|||
1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort |
|||
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 |
|||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 |
|||
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 4.17 Using where |
|||
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where |
|||
4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where |
|||
Warnings: |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10 |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
s_name s_address |
|||
Supplier#000000010 Saygah3gYWMp72i PY |
|||
DROP DATABASE dbt3_s001; |
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
set use_stat_tables=@save_use_stat_tables; |
|||
@ -0,0 +1,119 @@ |
|||
SET SESSION STORAGE_ENGINE='InnoDB'; |
|||
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; |
|||
set optimizer_switch='extended_keys=on'; |
|||
select @@global.use_stat_tables; |
|||
@@global.use_stat_tables |
|||
COMPLEMENTARY |
|||
select @@session.use_stat_tables; |
|||
@@session.use_stat_tables |
|||
COMPLEMENTARY |
|||
set @save_use_stat_tables=@@use_stat_tables; |
|||
set use_stat_tables='preferably'; |
|||
DROP DATABASE IF EXISTS dbt3_s001; |
|||
CREATE DATABASE dbt3_s001; |
|||
use dbt3_s001; |
|||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; |
|||
EXPLAIN EXTENDED select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
id select_type table type possible_keys key key_len ref rows filtered Extra |
|||
1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort |
|||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 |
|||
1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where |
|||
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where |
|||
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where |
|||
4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where |
|||
Warnings: |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10 |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
s_name s_address |
|||
Supplier#000000010 Saygah3gYWMp72i PY |
|||
set optimizer_use_condition_selectivity=3; |
|||
EXPLAIN EXTENDED select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
id select_type table type possible_keys key key_len ref rows filtered Extra |
|||
1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort |
|||
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 |
|||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 |
|||
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 4.17 Using where |
|||
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where |
|||
4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where |
|||
Warnings: |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 |
|||
Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10 |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
s_name s_address |
|||
Supplier#000000010 Saygah3gYWMp72i PY |
|||
DROP DATABASE dbt3_s001; |
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
set use_stat_tables=@save_use_stat_tables; |
|||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test; |
|||
SET SESSION STORAGE_ENGINE=DEFAULT; |
|||
@ -0,0 +1,101 @@ |
|||
SET @start_global_value = @@global.optimizer_use_condition_selectivity; |
|||
SELECT @start_global_value; |
|||
@start_global_value |
|||
1 |
|||
SET @start_session_value = @@session.optimizer_use_condition_selectivity; |
|||
SELECT @start_session_value; |
|||
@start_session_value |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_01-------------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_02-------------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity = 1; |
|||
@@global.optimizer_use_condition_selectivity = 1 |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity = 1; |
|||
@@session.optimizer_use_condition_selectivity = 1 |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_03-------------------------#' |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
2 |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
3 |
|||
'#--------------------FN_DYNVARS_115_04-------------------------#' |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
2 |
|||
SET @@session.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
3 |
|||
'#------------------FN_DYNVARS_115_05-----------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = ON; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@global.optimizer_use_condition_selectivity = OFF; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@session.optimizer_use_condition_selectivity = 65530.34; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@session.optimizer_use_condition_selectivity = test; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
'#------------------FN_DYNVARS_115_06-----------------------#' |
|||
SELECT @@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
@@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
1 |
|||
'#------------------FN_DYNVARS_115_07-----------------------#' |
|||
SELECT @@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
@@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
1 |
|||
'#---------------------FN_DYNVARS_115_08----------------------#' |
|||
SET @@optimizer_use_condition_selectivity = 1; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity; |
|||
@@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity |
|||
0 |
|||
'#---------------------FN_DYNVARS_115_09----------------------#' |
|||
SET @@optimizer_use_condition_selectivity = 2; |
|||
SELECT @@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity; |
|||
@@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity |
|||
1 |
|||
SELECT @@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity; |
|||
@@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = @start_global_value; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = @start_session_value; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
@ -0,0 +1,138 @@ |
|||
|
|||
--source include/load_sysvars.inc |
|||
|
|||
################################################################# |
|||
# START OF optimizer_use_condition_selectivity TESTS # |
|||
################################################################# |
|||
|
|||
|
|||
############################################################# |
|||
# Save initial value # |
|||
############################################################# |
|||
|
|||
SET @start_global_value = @@global.optimizer_use_condition_selectivity; |
|||
SELECT @start_global_value; |
|||
SET @start_session_value = @@session.optimizer_use_condition_selectivity; |
|||
SELECT @start_session_value; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_01-------------------------#' |
|||
######################################################################### |
|||
# Display the DEFAULT value of optimizer_use_condition_selectivity # |
|||
######################################################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
|
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_02-------------------------#' |
|||
######################################################################### |
|||
# Check the DEFAULT value of optimizer_use_condition_selectivity # |
|||
######################################################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity = 1; |
|||
|
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity = 1; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_03-------------------------#' |
|||
############################################################################################# |
|||
# Change the value of optimizer_use_condition_selectivity to a valid value for GLOBAL Scope # |
|||
############################################################################################# |
|||
|
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_04-------------------------#' |
|||
############################################################################################# |
|||
# Change the value of optimizer_use_condition_selectivity to a valid value for SESSION Scope# |
|||
############################################################################################# |
|||
|
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#------------------FN_DYNVARS_115_05-----------------------#' |
|||
############################################################################### |
|||
# Change the value of optimizer_use_condition_selectivity to an invalid value # |
|||
############################################################################## |
|||
|
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.optimizer_use_condition_selectivity = ON; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.optimizer_use_condition_selectivity = OFF; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.optimizer_use_condition_selectivity = 65530.34; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.optimizer_use_condition_selectivity = test; |
|||
|
|||
--echo '#------------------FN_DYNVARS_115_06-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in GLOBAL Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
|
|||
SELECT @@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
|
|||
--echo '#------------------FN_DYNVARS_115_07-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in SESSION Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
SELECT @@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
|
|||
|
|||
--echo '#---------------------FN_DYNVARS_115_08----------------------#' |
|||
############################################################################### |
|||
# Check if global and session variable are independent of each other # |
|||
############################################################################### |
|||
|
|||
SET @@optimizer_use_condition_selectivity = 1; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#---------------------FN_DYNVARS_115_09----------------------#' |
|||
############################################################################### |
|||
# Check if accessing variable with SESSION,LOCAL and without SCOPE points # |
|||
# to same session variable # |
|||
############################################################################### |
|||
|
|||
SET @@optimizer_use_condition_selectivity = 2; |
|||
SELECT @@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity; |
|||
SELECT @@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
#################################### |
|||
# Restore initial value # |
|||
#################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = @start_global_value; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = @start_session_value; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
######################################################################## |
|||
# END OF optimizer_use_condition_selectivity TESTS # |
|||
######################################################################## |
|||
|
|||
@ -0,0 +1,65 @@ |
|||
--source include/have_stat_tables.inc |
|||
|
|||
select @@global.use_stat_tables; |
|||
select @@session.use_stat_tables; |
|||
|
|||
set @save_use_stat_tables=@@use_stat_tables; |
|||
|
|||
set use_stat_tables='preferably'; |
|||
|
|||
--disable_warnings |
|||
DROP DATABASE IF EXISTS dbt3_s001; |
|||
--enable_warnings |
|||
|
|||
CREATE DATABASE dbt3_s001; |
|||
|
|||
use dbt3_s001; |
|||
|
|||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; |
|||
|
|||
--disable_query_log |
|||
--disable_result_log |
|||
--disable_warnings |
|||
--source include/dbt3_s001.inc |
|||
|
|||
ANALYZE TABLE |
|||
customer, lineitem, nation, orders, part, partsupp, region, supplier; |
|||
FLUSH TABLE |
|||
customer, lineitem, nation, orders, part, partsupp, region, supplier; |
|||
--enable_warnings |
|||
--enable_result_log |
|||
--enable_query_log |
|||
|
|||
let $Q20= |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
|
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
DROP DATABASE dbt3_s001; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
@ -0,0 +1,12 @@ |
|||
--source include/have_innodb.inc |
|||
|
|||
SET SESSION STORAGE_ENGINE='InnoDB'; |
|||
|
|||
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; |
|||
set optimizer_switch='extended_keys=on'; |
|||
|
|||
--source selectivity.test |
|||
|
|||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test; |
|||
|
|||
SET SESSION STORAGE_ENGINE=DEFAULT; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue