mirror of
https://github.com/MariaDB/server.git
synced 2025-12-28 08:10:14 +00:00
MDEV-36761 Remove @@new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS in 12.1
Remove the FIX_INDEX_STATS_FOR_ALL_NULLS flag from @@new_mode. The new behavior is now always on.
This commit is contained in:
parent
ba00960fda
commit
5f845854fb
@ -1,4 +1,3 @@
|
||||
SET @session_start_value = @@new_mode;
|
||||
# Small driving table
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300);
|
||||
@ -14,9 +13,6 @@ ANALYZE TABLE t2 PERSISTENT FOR ALL;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status Table is already up to date
|
||||
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
|
||||
Warnings:
|
||||
Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release
|
||||
# NULL-rejecting equality t1.b = t2.b will not return any matches
|
||||
# because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is
|
||||
# a special value meaning "very few" rows
|
||||
@ -82,23 +78,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,const 11 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t3`.`b` is null
|
||||
# In the old mode (null-aware estimation is not enabled), "rows" > 1
|
||||
SET @@new_mode = "";
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b;
|
||||
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 Using where
|
||||
1 SIMPLE t2 ref key_b key_b 5 test.t1.b 100 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`
|
||||
# Insert some non-NULL values and re-collect the stats
|
||||
INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100;
|
||||
ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab);
|
||||
Table Op Msg_type Msg_text
|
||||
test.t3 analyze status Engine-independent statistics collected
|
||||
test.t3 analyze status OK
|
||||
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
|
||||
Warnings:
|
||||
Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b;
|
||||
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 Using where
|
||||
@ -158,5 +143,4 @@ EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t2 ref i1 i1 66 test.t1.a,test.t1.a 1 Using where
|
||||
SET @@new_mode = @session_start_value;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
--source include/have_sequence.inc
|
||||
|
||||
SET @session_start_value = @@new_mode;
|
||||
|
||||
--echo # Small driving table
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300);
|
||||
@ -15,8 +13,6 @@ INSERT INTO t2 SELECT seq/100, NULL FROM seq_1_to_1000;
|
||||
|
||||
ANALYZE TABLE t2 PERSISTENT FOR ALL;
|
||||
|
||||
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
|
||||
|
||||
--echo # NULL-rejecting equality t1.b = t2.b will not return any matches
|
||||
--echo # because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is
|
||||
--echo # a special value meaning "very few" rows
|
||||
@ -52,16 +48,11 @@ EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b <=> t3.b;
|
||||
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t3.b is NULL;
|
||||
|
||||
--echo # In the old mode (null-aware estimation is not enabled), "rows" > 1
|
||||
SET @@new_mode = "";
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b;
|
||||
|
||||
--echo # Insert some non-NULL values and re-collect the stats
|
||||
INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100;
|
||||
|
||||
ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab);
|
||||
|
||||
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b;
|
||||
|
||||
--echo # Test composite index for 3 columns. Key prefix is used for access
|
||||
@ -99,5 +90,4 @@ ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (i1);
|
||||
|
||||
EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a;
|
||||
|
||||
SET @@new_mode = @session_start_value;
|
||||
DROP TABLE t1, t2;
|
||||
@ -4164,11 +4164,10 @@ void set_statistics_for_table(THD *thd, TABLE *table)
|
||||
(check_eits_preferred(thd) &&
|
||||
table->stats_is_read &&
|
||||
key_info->read_stats->avg_frequency_is_inited() &&
|
||||
key_info->read_stats->has_stats(thd));
|
||||
key_info->read_stats->has_stats());
|
||||
|
||||
// Fill out `all_nulls_key_parts` bitmap
|
||||
if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS) &&
|
||||
key_info->is_statistics_from_stat_tables)
|
||||
if (key_info->is_statistics_from_stat_tables)
|
||||
{
|
||||
for (uint part_idx= 0; part_idx < key_info->usable_key_parts; part_idx++)
|
||||
{
|
||||
|
||||
@ -614,13 +614,7 @@ public:
|
||||
|
||||
void mark_stats_as_read() { stats_were_read= true; }
|
||||
|
||||
bool has_stats(THD *thd) const
|
||||
{
|
||||
if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS))
|
||||
return stats_were_read;
|
||||
else
|
||||
return get_avg_frequency(0) > 0.5;
|
||||
}
|
||||
bool has_stats() const { return stats_were_read; }
|
||||
|
||||
bool avg_frequency_is_inited() { return avg_frequency != NULL; }
|
||||
|
||||
|
||||
@ -4174,9 +4174,9 @@ static Sys_var_set Sys_old_behavior(
|
||||
*/
|
||||
static const char *new_mode_all_names[]=
|
||||
{
|
||||
"FIX_DISK_TMPTABLE_COSTS",
|
||||
"FIX_DISK_TMPTABLE_COSTS", // Default from here, See NEW_MODE_MAX
|
||||
"FIX_INDEX_STATS_FOR_ALL_NULLS",
|
||||
"TEST_WARNING1", // Default from here, See NEW_MODE_MAX
|
||||
"TEST_WARNING1",
|
||||
"TEST_WARNING2",
|
||||
0
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user