diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-01-30 22:36:51 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-01-30 22:36:51 +0530 |
commit | 072b39da66d9c1693ca832eb97f2d63b238cc412 (patch) | |
tree | 0f4dfe87543b194a0a4b495fc4f9372ac6ae78de /mysql-test/r | |
parent | b87c342da5e51e112e06b36d8b95037f182bdb0e (diff) | |
download | mariadb-git-072b39da66d9c1693ca832eb97f2d63b238cc412.tar.gz |
MDEV-22583: Selectivity for BIT columns in filtered column for EXPLAIN is incorrect
For BIT columns when EITS is collected, we store the integral value in
text representation in the min and max fields of the statistical table
When this value is retrieved from the statistical table to original table
field then we try to store the text representation in the original field
which is INCORRECT.
The value that is retrieved should be converted to integral type and that
value should be stored back in the original field. This would get us the
correct estimate for selectivity of the predicate.
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/selectivity.result | 24 | ||||
-rw-r--r-- | mysql-test/r/selectivity_innodb.result | 24 |
2 files changed, 48 insertions, 0 deletions
diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result index 10af9265649..4d45d6b175b 100644 --- a/mysql-test/r/selectivity.result +++ b/mysql-test/r/selectivity.result @@ -1887,4 +1887,28 @@ a b set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1; # End of 10.1 tests +# +# MDEV-22583: Selectivity for BIT columns in filtered column for EXPLAIN is incorrect +# +SET optimizer_use_condition_selectivity=4; +SET histogram_size=255; +CREATE TABLE t1 (a BIT(32), b INT); +INSERT INTO t1 VALUES (80, 80), (81, 81), (82, 82); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 +SELECT HEX(a), b from t1 where t1.a >= 81; +HEX(a) b +51 81 +52 82 +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +DROP TABLE t1; +# End of 10.2 tests set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result index ee0f56ae7ed..b97bbf8153f 100644 --- a/mysql-test/r/selectivity_innodb.result +++ b/mysql-test/r/selectivity_innodb.result @@ -1897,6 +1897,30 @@ a b set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1; # End of 10.1 tests +# +# MDEV-22583: Selectivity for BIT columns in filtered column for EXPLAIN is incorrect +# +SET optimizer_use_condition_selectivity=4; +SET histogram_size=255; +CREATE TABLE t1 (a BIT(32), b INT); +INSERT INTO t1 VALUES (80, 80), (81, 81), (82, 82); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 +SELECT HEX(a), b from t1 where t1.a >= 81; +HEX(a) b +51 81 +52 82 +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +DROP TABLE t1; +# End of 10.2 tests set @@global.histogram_size=@save_histogram_size; set optimizer_switch=@save_optimizer_switch_for_selectivity_test; set @tmp_ust= @@use_stat_tables; |