Skip to content

Commit 32940e3

Browse files
committed
MDEV-37723: TPROC-H Query4...: Remove @@new_mode=FIX_DISK_TMPTABLE_COSTS in 12.1
In 12.1, remove the FIX_DISK_TMPTABLE_COSTS flag from @@new_mode. The new behavior is now always on.
1 parent c976b52 commit 32940e3

File tree

10 files changed

+22
-107
lines changed

10 files changed

+22
-107
lines changed

mysql-test/main/costs.result

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ from seq_1_to_7000 a, seq_1_to_3 b;
145145
set
146146
@save_mhts= @@max_heap_table_size,
147147
@@max_heap_table_size=16384;
148-
set @save_new_mode=@@new_mode;
149-
set new_mode=CONCAT(@@new_mode, ',FIX_DISK_TMPTABLE_COSTS');
150-
# This should use: t1, FirstMatch(t2)
148+
# This should use "t1, FirstMatch(t2)". Not "t1, SJ-Materialization(t2)".
151149
explain format=json
152150
select c, count(*) as dc
153151
from t1
@@ -198,74 +196,5 @@ EXPLAIN
198196
}
199197
}
200198
}
201-
SET new_mode = REPLACE(@@new_mode, 'FIX_DISK_TMPTABLE_COSTS', '');
202-
# This should use: t1, SJ-Materialization(t2)
203-
explain format=json
204-
select c, count(*) as dc
205-
from t1
206-
where
207-
b >= date '1993-06-01' and b < date '1993-06-01' + interval '3' month and
208-
exists (select * from t2 where e = t1.a and g < h)
209-
group by c;
210-
EXPLAIN
211-
{
212-
"query_block": {
213-
"select_id": 1,
214-
"cost": 12.39219425,
215-
"filesort": {
216-
"sort_key": "t1.c",
217-
"temporary_table": {
218-
"nested_loop": [
219-
{
220-
"table": {
221-
"table_name": "t1",
222-
"access_type": "ALL",
223-
"possible_keys": ["PRIMARY", "t1_ix1"],
224-
"loops": 1,
225-
"rows": 7000,
226-
"cost": 1.1518548,
227-
"filtered": 100,
228-
"attached_condition": "t1.b >= DATE'1993-06-01' and t1.b < <cache>(DATE'1993-06-01' + interval '3' month)"
229-
}
230-
},
231-
{
232-
"table": {
233-
"table_name": "<subquery2>",
234-
"access_type": "eq_ref",
235-
"possible_keys": ["distinct_key"],
236-
"key": "distinct_key",
237-
"key_length": "4",
238-
"used_key_parts": ["e"],
239-
"ref": ["func"],
240-
"rows": 1,
241-
"filtered": 100,
242-
"materialized": {
243-
"unique": 1,
244-
"query_block": {
245-
"select_id": 2,
246-
"nested_loop": [
247-
{
248-
"table": {
249-
"table_name": "t2",
250-
"access_type": "ALL",
251-
"possible_keys": ["PRIMARY"],
252-
"loops": 1,
253-
"rows": 21000,
254-
"cost": 3.4338548,
255-
"filtered": 100,
256-
"attached_condition": "t2.g < t2.h"
257-
}
258-
}
259-
]
260-
}
261-
}
262-
}
263-
}
264-
]
265-
}
266-
}
267-
}
268-
}
269-
set new_mode=@save_new_mode;
270199
set max_heap_table_size=@save_mhts;
271200
drop table t1, t2;

mysql-test/main/costs.test

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ set
141141
@save_mhts= @@max_heap_table_size,
142142
@@max_heap_table_size=16384;
143143

144-
set @save_new_mode=@@new_mode;
145-
let $q=
144+
145+
--echo # This should use "t1, FirstMatch(t2)". Not "t1, SJ-Materialization(t2)".
146146
explain format=json
147147
select c, count(*) as dc
148148
from t1
@@ -151,15 +151,5 @@ where
151151
exists (select * from t2 where e = t1.a and g < h)
152152
group by c;
153153

154-
set new_mode=CONCAT(@@new_mode, ',FIX_DISK_TMPTABLE_COSTS');
155-
--echo # This should use: t1, FirstMatch(t2)
156-
eval $q;
157-
158-
SET new_mode = REPLACE(@@new_mode, 'FIX_DISK_TMPTABLE_COSTS', '');
159-
160-
--echo # This should use: t1, SJ-Materialization(t2)
161-
eval $q;
162-
163-
set new_mode=@save_new_mode;
164154
set max_heap_table_size=@save_mhts;
165155
drop table t1, t2;

mysql-test/main/opt_trace.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12172,8 +12172,8 @@ JS
1217212172
"org_cost": 1.159965,
1217312173
"postjoin_cost": 4.020888502,
1217412174
"one_splitting_cost": 5.180853502,
12175-
"unsplit_postjoin_cost": 32.78652054,
12176-
"unsplit_cost": 148.7830205,
12175+
"unsplit_postjoin_cost": 159.1588125,
12176+
"unsplit_cost": 275.1553125,
1217712177
"rows": 100,
1217812178
"refills": 5,
1217912179
"total_splitting_cost": 25.90426751,

mysql-test/main/subselect3.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,9 @@ set @@optimizer_switch='firstmatch=off,materialization=off';
11671167
set @@max_heap_table_size= 16384;
11681168
explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a);
11691169
id select_type table type possible_keys key key_len ref rows Extra
1170-
1 PRIMARY E ALL NULL NULL NULL NULL 5 Start temporary
1171-
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
1170+
1 PRIMARY A ALL NULL NULL NULL NULL 10
11721171
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
1172+
1 PRIMARY E ALL NULL NULL NULL NULL 5 Start temporary; Using join buffer (flat, BNL join)
11731173
1 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
11741174
1 PRIMARY D ALL NULL NULL NULL NULL 10 Using where; End temporary; Using join buffer (flat, BNL join)
11751175
flush status;

mysql-test/suite/sys_vars/r/new_mode.result

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ SELECT @session_start_value;
77
@session_start_value
88

99
SET @@global.new_mode = "FIX_DISK_TMPTABLE_COSTS";
10+
Warnings:
11+
Warning 4200 The setting 'new_mode=FIX_DISK_TMPTABLE_COSTS' is ignored. It only exists for compatibility with old installations and will be removed in a future release
1012
SELECT @@global.new_mode;
1113
@@global.new_mode
12-
FIX_DISK_TMPTABLE_COSTS
14+
1315
SELECT @@session.new_mode;
1416
@@session.new_mode
1517

@@ -22,17 +24,19 @@ SELECT @@session.new_mode;
2224

2325
SET @@session.new_mode = "FIX_DISK_TMPTABLE_COSTS,TEST_WARNING1";
2426
Warnings:
27+
Warning 4200 The setting 'new_mode=FIX_DISK_TMPTABLE_COSTS' is ignored. It only exists for compatibility with old installations and will be removed in a future release
2528
Warning 4200 The setting 'new_mode=TEST_WARNING1' is ignored. It only exists for compatibility with old installations and will be removed in a future release
2629
SET @@session.new_mode = "FIX_DISK_TMPTABLE_COSTS,TEST_WARNING1,TEST_WARNING2";
2730
Warnings:
31+
Warning 4200 The setting 'new_mode=FIX_DISK_TMPTABLE_COSTS' is ignored. It only exists for compatibility with old installations and will be removed in a future release
2832
Warning 4200 The setting 'new_mode=TEST_WARNING1' is ignored. It only exists for compatibility with old installations and will be removed in a future release
2933
Warning 4200 The setting 'new_mode=TEST_WARNING2' is ignored. It only exists for compatibility with old installations and will be removed in a future release
3034
SET @@session.new_mode = "FIX_DISK_TMPTABLE_COSTS,TEST_WARNING1,TEST_WARNING2,TEST_WARNING3";
3135
ERROR 42000: Variable 'new_mode' can't be set to the value of 'TEST_WARNING3'
3236
SET @@session.new_mode = "ALL";
3337
select @@session.new_mode;
3438
@@session.new_mode
35-
FIX_DISK_TMPTABLE_COSTS
39+
3640
SET @@global.new_mode = NULL;
3741
ERROR 42000: Variable 'new_mode' can't be set to the value of 'NULL'
3842
SET @@global.new_mode = '';

mysql-test/suite/sys_vars/r/sysvars_server_embedded.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ VARIABLE_COMMENT Used to introduce new behavior to existing MariaDB versions
24192419
NUMERIC_MIN_VALUE NULL
24202420
NUMERIC_MAX_VALUE NULL
24212421
NUMERIC_BLOCK_SIZE NULL
2422-
ENUM_VALUE_LIST FIX_DISK_TMPTABLE_COSTS
2422+
ENUM_VALUE_LIST
24232423
READ_ONLY NO
24242424
COMMAND_LINE_ARGUMENT REQUIRED
24252425
VARIABLE_NAME NOTE_VERBOSITY

mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ VARIABLE_COMMENT Used to introduce new behavior to existing MariaDB versions
26392639
NUMERIC_MIN_VALUE NULL
26402640
NUMERIC_MAX_VALUE NULL
26412641
NUMERIC_BLOCK_SIZE NULL
2642-
ENUM_VALUE_LIST FIX_DISK_TMPTABLE_COSTS
2642+
ENUM_VALUE_LIST
26432643
READ_ONLY NO
26442644
COMMAND_LINE_ARGUMENT REQUIRED
26452645
VARIABLE_NAME NOTE_VERBOSITY

sql/opt_subselect.cc

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,19 +2777,10 @@ get_tmp_table_costs(THD *thd, double row_count, uint row_size, bool blobs_used,
27772777
tmp_table_optimizer_costs.row_copy_cost :
27782778
0);
27792779
/* Disk based table */
2780-
if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_DISK_TMPTABLE_COSTS))
2781-
{
2782-
cost.lookup= ((tmp_table_optimizer_costs.key_lookup_cost +
2783-
tmp_table_optimizer_costs.disk_read_cost *
2784-
tmp_table_optimizer_costs.disk_read_ratio) +
2785-
row_copy_cost);
2786-
}
2787-
else
2788-
{
2789-
cost.lookup= ((tmp_table_optimizer_costs.key_lookup_cost *
2790-
tmp_table_optimizer_costs.disk_read_ratio) +
2791-
row_copy_cost);
2792-
}
2780+
cost.lookup= ((tmp_table_optimizer_costs.key_lookup_cost +
2781+
tmp_table_optimizer_costs.disk_read_cost *
2782+
tmp_table_optimizer_costs.disk_read_ratio) +
2783+
row_copy_cost);
27932784
/*
27942785
Don't have numbers for cost of writing, assume it's the same as cost
27952786
of reading for lack of a better number.

sql/sql_class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ void old_mode_deprecated_warnings(ulonglong v);
227227
See sys_vars.cc /new_mode_all_names
228228
*/
229229

230-
#define NEW_MODE_FIX_DISK_TMPTABLE_COSTS (1 << 0)
231-
#define NEW_MODE_MAX 1
230+
#define NEW_MODE_MAX 0
232231

233232
/* Definitions above that have transitioned from new behaviour to default */
234233

235234
#define NOW_DEFAULT -1
236235
#define NEW_MODE_TEST_WARNING1 NOW_DEFAULT
237236
#define NEW_MODE_TEST_WARNING2 NOW_DEFAULT
237+
#define NEW_MODE_FIX_DISK_TMPTABLE_COSTS NOW_DEFAULT
238238

239239
#define TEST_NEW_MODE_FLAG(thd, flag) \
240240
(flag == NOW_DEFAULT ? TRUE : thd->variables.new_behavior & flag)

sql/sys_vars.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4182,6 +4182,7 @@ static const char *new_mode_all_names[]=
41824182

41834183
static int new_mode_hidden_names[] =
41844184
{
4185+
0, // FIX_DISK_TMPTABLE_COSTS
41854186
1, // TEST_WARNING1
41864187
2, // TEST_WARNING2
41874188
-1 // End of list

0 commit comments

Comments
 (0)