From d3e511d42111c23df93cdb1d3b464dcb711cae07 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 8 Jan 2022 22:54:23 +0300 Subject: [PATCH] MDEV-27243: Estimation for filtered rows less precise ... #7 Added a testcase --- mysql-test/main/statistics_json.result | 14 ++++++++++++++ mysql-test/main/statistics_json.test | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 0a58faa3143..5de350fb21d 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -8241,3 +8241,17 @@ analyze select COUNT(*) FROM t1 WHERE a <='bar'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 50.00 50.00 Using where drop table t1; +# +# MDEV-27243: Estimation for filtered rows less precise ... #7 +# (Testcase only) +CREATE TABLE t1 (f TIME); +INSERT INTO t1 SELECT IF(seq%2,'00:00:00',SEC_TO_TIME(seq+7200)) FROM seq_1_to_1000; +SET histogram_type= JSON_HB; +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 +ANALYZE SELECT * FROM t1 WHERE f > '00:01:00'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 50.00 50.00 Using where +drop table t1; diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test index 2b19ff14a2f..7ec6c691a99 100644 --- a/mysql-test/main/statistics_json.test +++ b/mysql-test/main/statistics_json.test @@ -416,3 +416,16 @@ analyze select COUNT(*) FROM t1 WHERE a >='bar'; analyze select COUNT(*) FROM t1 WHERE a <='bar'; drop table t1; + +--echo # +--echo # MDEV-27243: Estimation for filtered rows less precise ... #7 +--echo # (Testcase only) + +CREATE TABLE t1 (f TIME); +INSERT INTO t1 SELECT IF(seq%2,'00:00:00',SEC_TO_TIME(seq+7200)) FROM seq_1_to_1000; + +SET histogram_type= JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +ANALYZE SELECT * FROM t1 WHERE f > '00:01:00'; +drop table t1; +