1 # Continuation of tests for optimizer trace
3 --source include/have_optimizer_trace.inc
5 let $DEFAULT_TRACE_MEM_SIZE=1048576; # 1MB
6 eval
set optimizer_trace_max_mem_size=$DEFAULT_TRACE_MEM_SIZE;
8 set end_markers_in_json=on;
9 set optimizer_trace=
"enabled=on";
11 --echo # check that
if a sub-
statement should not be traced,
12 --echo # it is not traced even
if inside a traced top
statement
14 set optimizer_trace_offset=0, optimizer_trace_limit=100;
16 create
function f1(arg
char(1)) returns
int
19 declare dummy varchar(1);
20 select 1 into res from dual;
21 select TRACE+NULL into dummy from information_schema.OPTIMIZER_TRACE
limit 1;
22 select 2 into res from dual;
25 # ps-protocol specific note: as we asked to retain all traces,
26 # we see the one of PREPARE too.
29 # we should not see the trace of "select TRACE+NULL..."
30 # because tracing is disabled when OPTIMIZER_TRACE table is used.
31 select * from information_schema.OPTIMIZER_TRACE|
33 set optimizer_trace_offset=
default, optimizer_trace_limit=
default;
36 --echo # check that
if a tracing gets disabled in a routine
's body,
37 --echo # substatements are not traced
39 set optimizer_trace_offset=0, optimizer_trace_limit=100;
41 create function f1(arg char(1)) returns int
44 declare dummy varchar(1);
45 set optimizer_trace="enabled=off";
46 select 1 into res from dual;
47 select TRACE+NULL into dummy from information_schema.OPTIMIZER_TRACE limit 1;
48 select 2 into res from dual;
53 select * from information_schema.OPTIMIZER_TRACE|
55 set optimizer_trace_offset=default, optimizer_trace_limit=default;
56 select @@optimizer_trace;
57 set optimizer_trace="enabled=on";
61 --echo # Check that if a sub-statement reads OPTIMIZER_TRACE,
62 --echo # thus reading the unfinished trace of its caller statement,
63 --echo # there is no crash.
66 create temporary table optt
67 (id int primary key auto_increment,
70 create table t1 (a int, key(a));
71 insert into t1 values(2);
72 set optimizer_trace_offset=0, optimizer_trace_limit=100;
74 create function f1(arg char(1)) returns int
77 insert into optt select NULL, QUERY, TRACE from information_schema.OPTIMIZER_TRACE;
80 select * from t1 where a in (select f1("c") from t1)|
83 set optimizer_trace="enabled=off";
84 --echo this should find unfinished traces
85 select count(*) from optt where TRACE NOT LIKE "%] /* steps */\n}";
86 select count(*)<>0 from optt;
87 --echo this should not
88 select count(*) from information_schema.OPTIMIZER_TRACE where TRACE NOT LIKE "%] /* steps */\n}";
89 select count(*)<>0 from information_schema.OPTIMIZER_TRACE;
91 set optimizer_trace_offset=default, optimizer_trace_limit=default;
92 drop temporary table optt;
95 set optimizer_trace="enabled=on";
98 --echo # check of crash with I_S.VIEWS (TABLE_LIST::alias==NULL)
100 create table t1(a int, b int);
101 create view v1 as select a from t1;
102 select VIEW_DEFINITION from information_schema.VIEWS
103 where TABLE_SCHEMA="test" and TABLE_NAME="v1";
104 select locate("\"view\": \"v1\"", TRACE) != 0
105 from information_schema.OPTIMIZER_TRACE;
110 --echo # check for readable display of BIT values
112 create table t1 (a bit(5), key(a));
113 insert into t1 values(b'00000
'),(b'01101
');
114 select cast(a as unsigned) from t1 where a > b'01100
';
115 # Note that in the trace we get either 0x0c or 12
116 select TRACE from information_schema.OPTIMIZER_TRACE;
120 --echo # check that trace lists all pushed down ON conditions
122 create table t1 (i int not null);
123 insert into t1 values (0), (2),(3),(4);
124 create table t2 (i int not null);
125 insert into t2 values (0),(1), (3),(4);
126 create table t3 (i int not null);
127 insert into t3 values (0),(1),(2), (4);
138 select TRACE from information_schema.OPTIMIZER_TRACE;
142 --echo # test of tracing a query with an HAVING condition, in
143 --echo # ps-protocol, does not crash
145 # Comes from having.test
147 CREATE TABLE t1 (f1 INT, f2 VARCHAR(1));
148 INSERT INTO t1 VALUES (16,'f
');
149 INSERT INTO t1 VALUES (16,'f
');
150 CREATE TABLE t2 (f1 INT, f2 VARCHAR(1));
151 INSERT INTO t2 VALUES (13,'f
');
152 INSERT INTO t2 VALUES (20,'f
');
153 CREATE TABLE t3 (f1 INT, f2 VARCHAR(1));
154 INSERT INTO t3 VALUES (7,'f
');
157 STRAIGHT_JOIN (t2 JOIN t3 ON t3.f2 = t2.f2 ) ON t3 .f2 = t2 .f2
158 HAVING ('v
', 'i') NOT IN (SELECT f2, MIN(f2) FROM t1)
160 --replace_regex /("sort_buffer_size":) [0-9]+/\1 "NNN"/
161 select TRACE from information_schema.OPTIMIZER_TRACE;
163 DROP TABLES t1,t2,t3;
166 --echo # Test that tracing a query with a materialized FROM-clause
167 --echo # derived table using a GROUP BY, does not crash
169 # Comes from profiling.test
170 create table t1 (a int, b int);
171 insert into t1 values (1,1), (2,null), (3, 4);
172 select max(x) from (select sum(a) as x from t1 group by b) as teeone;
173 --replace_regex /("sort_buffer_size":) [0-9]+/\1 "NNN"/
174 select TRACE from information_schema.OPTIMIZER_TRACE;
178 --echo # To have no crash above, we had to restore the ref_array at
179 --echo # end of JOIN::exec(). This impacts how the query looks like,
180 --echo # but not too much, as seen in the error message below.
181 --echo # Comes from func_gconcat.test.
183 CREATE TABLE t1(f1 int);
184 INSERT INTO t1 values (0),(0);
185 set optimizer_trace="enabled=off";
186 --disable_ps_protocol
187 --error ER_ILLEGAL_VALUE_FOR_TYPE
188 SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d));
190 set optimizer_trace="enabled=on";
191 --disable_ps_protocol
192 --error ER_ILLEGAL_VALUE_FOR_TYPE
193 SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d));
198 --echo # Check that SQL PREPARE and SQL EXECUTE each produce one trace.
200 set optimizer_trace_offset=0, optimizer_trace_limit=100;
201 prepare stmt from "select 1";
202 select * from information_schema.OPTIMIZER_TRACE;
203 set optimizer_trace_offset=0, optimizer_trace_limit=100;
205 select * from information_schema.OPTIMIZER_TRACE;
206 deallocate prepare stmt;
207 set optimizer_trace_offset=default, optimizer_trace_limit=default;
210 --echo # Test of SELECTs in IF in stored routine.
211 --echo # Same test for CASE WHEN.
213 create table t1 (a int);
215 create procedure p1()
217 if exists(select 1) then
218 insert into t1 values(1);
220 if exists(select 2) then
221 insert into t1 values(2);
223 if (select count(*) from t1) then
224 insert into t1 values(3);
226 set @a=(select count(a) from t1 where a>0);
227 case (select count(a) from t1 where a>1)
228 when 2 then set @b=2;
233 set optimizer_trace_offset=0, optimizer_trace_limit=100;
234 set @old_max=@@optimizer_trace_max_mem_size;
235 set optimizer_trace_max_mem_size=40000;
237 # SET @a=(SELECT) is not traced because part of SET
238 # which is a real command and not traced.
239 select * from information_schema.OPTIMIZER_TRACE;
242 set optimizer_trace_max_mem_size=@old_max;
247 --echo # Test of tracing of DO.
250 set optimizer_trace_offset=0, optimizer_trace_limit=100;
252 select * from information_schema.OPTIMIZER_TRACE;
255 --echo # Test of tracing of subquery used in parameter of routine call
257 create table t1(a int);
258 insert into t1 values(1),(2);
260 create procedure p1(x int)
263 set b=(select 2+x from dual);
266 set optimizer_trace_offset=0, optimizer_trace_limit=100;
267 call p1((select a from t1 limit 1));
268 select * from information_schema.OPTIMIZER_TRACE;
271 set optimizer_trace_offset=default, optimizer_trace_limit=default;
274 --echo # Test that printing expanded query does not alter query's
276 --echo # Comes from ctype_utf8mb4_heap.test
278 create
table t1 (f1 varchar(1) not null)
default charset utf8mb4;
279 insert into t1 values (
''), (
'');
280 select concat(concat(_latin1
'->',f1),_latin1
'<-') from t1;
281 select * from information_schema.optimizer_trace;
285 --echo
# Bug#12546331 - SEGFAULT IN SUBSELECT_INDEXSUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE
291 col_varchar_key varchar(1),
292 KEY col_int_key (col_int_key),
293 KEY col_varchar_key (col_varchar_key,col_int_key)
296 INSERT INTO t1 VALUES
322 col_varchar_key varchar(1),
323 KEY col_int_key (col_int_key),
324 KEY col_varchar_key (col_varchar_key,col_int_key)
327 INSERT INTO t2 VALUES
354 WHERE col_varchar_key >
'a'
355 OR ( 7 , 5 ) NOT IN (
356 SELECT col_int_nokey , col_int_key
364 --echo BUG#12552262 - INVALID JSON WITH TWO CALLS TO TEST_QUICK_SELECT
368 col_varchar_10_latin1_key varchar(10) DEFAULT NULL,
370 KEY col_int_key (col_int_key)
374 col_varchar_10_latin1_key varchar(10) DEFAULT NULL,
375 col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL,
377 KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key),
378 KEY col_int_key (col_int_key)
381 INSERT INTO t2 VALUES (
'qykbaqfyhz',
'l',NULL);
385 col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL,
386 col_varchar_10_latin1_key varchar(10) DEFAULT NULL,
387 KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key),
388 KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key)
391 INSERT INTO t3 VALUES (0,
's',
'it');
392 INSERT INTO t3 VALUES (9,
'IQTHK',
'JCAQM');
394 SELECT table2.col_int_key
396 LEFT
JOIN t1 AS table2 ON table1.col_int_key < table2.col_int_key
397 LEFT
JOIN t2 AS table3 ON table2.col_varchar_10_latin1_key >=
398 table3.col_varchar_10_utf8_key
401 select * from information_schema.optimizer_trace;
406 --echo Tests of tracing of the
"eq_ref optimization" of
plan search
409 # test for trace point "chosen:true","pruned_by_cost:true" and
410 # "added_to_eq_ref_extension:true" (from main.subquery_sj_none_jcl7)
412 create
table t0 (a
int);
413 insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
414 create
table t1 (a
int, b
int, key(a));
415 create
table t2 (a
int, b
int, key(a));
416 create
table t3 (a
int, b
int, key(a));
417 insert into t1 select a,a from t0;
418 insert into t2 select a,a from t0;
419 insert into t3 select a,a from t0;
421 set @old_opt_switch=@@optimizer_switch;
422 # The SET below must not be output, because only servers supporting
423 # semijoin will execute it (would make varying output).
424 if (`select locate(
'semijoin', @@optimizer_switch) > 0`)
427 set optimizer_switch=
"semijoin=off,materialization=off";
432 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
434 select * from information_schema.optimizer_trace;
435 set optimizer_switch=@old_opt_switch;
436 drop
table t0,t1,t2,t3;
438 # test for trace point "added_to_eq_ref_extension:false" (from main.derived)
441 OBJECTID
int(11) NOT NULL
default '0',
442 SORTORDER
int(11) NOT NULL auto_increment,
443 KEY t1_SortIndex (SORTORDER),
444 KEY t1_IdIndex (OBJECTID)
445 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
447 ID
int(11) default NULL,
448 PARID
int(11) default NULL,
449 UNIQUE
KEY t2_ID_IDX (ID),
450 KEY t2_PARID_IDX (PARID)
451 ) engine=MyISAM DEFAULT CHARSET=latin1;
452 INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2);
454 ID
int(11) default NULL,
455 DATA decimal(10,2) default NULL,
456 UNIQUE
KEY t3_ID_IDX (ID)
457 ) engine=MyISAM DEFAULT CHARSET=latin1;
458 INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75);
460 select 497, tmp.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID)
group by t2.ParID order by DATA DESC) as tmp;
461 select * from information_schema.optimizer_trace;
464 # test of multiple nested trace points "added_to_eq_ref_extension:true"
465 # (eq_ref optimization finding a sequence of eq_ref-joined tables) (from
469 t1_id bigint(21) NOT NULL auto_increment,
470 _field_72 varchar(128) DEFAULT
'' NOT NULL,
471 _field_95 varchar(32),
472 _field_115 tinyint(4) DEFAULT
'0' NOT NULL,
473 _field_122 tinyint(4) DEFAULT
'0' NOT NULL,
474 _field_126 tinyint(4),
475 _field_134 tinyint(4),
477 UNIQUE _field_72 (_field_72),
478 KEY _field_115 (_field_115),
479 KEY _field_122 (_field_122)
481 INSERT INTO t1 VALUES (1,
'admin',
'21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
482 INSERT INTO t1 VALUES (2,
'hroberts',
'7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
483 INSERT INTO t1 VALUES (3,
'guest',
'd41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
486 seq_0_id bigint(21) DEFAULT
'0' NOT NULL,
487 seq_1_id bigint(21) DEFAULT
'0' NOT NULL,
488 PRIMARY
KEY (seq_0_id,seq_1_id)
490 INSERT INTO t2 VALUES (1,1);
491 INSERT INTO t2 VALUES (2,1);
492 INSERT INTO t2 VALUES (2,2);
495 t3_id bigint(21) NOT NULL auto_increment,
496 _field_131 varchar(128),
497 _field_133 tinyint(4) DEFAULT
'0' NOT NULL,
498 _field_135 datetime DEFAULT
'0000-00-00 00:00:00' NOT NULL,
499 _field_137 tinyint(4),
500 _field_139 datetime DEFAULT
'0000-00-00 00:00:00' NOT NULL,
502 _field_142 tinyint(4) DEFAULT
'0' NOT NULL,
503 _field_145 tinyint(4) DEFAULT
'0' NOT NULL,
504 _field_148 tinyint(4) DEFAULT
'0' NOT NULL,
506 KEY _field_133 (_field_133),
507 KEY _field_135 (_field_135),
508 KEY _field_139 (_field_139),
509 KEY _field_142 (_field_142),
510 KEY _field_145 (_field_145),
511 KEY _field_148 (_field_148)
513 INSERT INTO t3 VALUES (1,
'test job 1',0,
'0000-00-00 00:00:00',0,
'1999-02-25 22:43:32',
'test\r\njob\r\n1',0,0,0);
514 INSERT INTO t3 VALUES (2,
'test job 2',0,
'0000-00-00 00:00:00',0,
'1999-02-26 21:08:04',
'',0,0,0);
517 seq_0_id bigint(21) DEFAULT
'0' NOT NULL,
518 seq_1_id bigint(21) DEFAULT
'0' NOT NULL,
519 PRIMARY
KEY (seq_0_id,seq_1_id)
521 INSERT INTO t4 VALUES (1,1);
522 INSERT INTO t4 VALUES (2,1);
525 t5_id bigint(21) NOT NULL auto_increment,
526 _field_149 tinyint(4),
527 _field_156 varchar(128) DEFAULT
'' NOT NULL,
528 _field_157 varchar(128) DEFAULT
'' NOT NULL,
529 _field_158 varchar(128) DEFAULT
'' NOT NULL,
530 _field_159 varchar(128) DEFAULT
'' NOT NULL,
531 _field_160 varchar(128) DEFAULT
'' NOT NULL,
532 _field_161 varchar(128) DEFAULT
'' NOT NULL,
534 KEY _field_156 (_field_156),
535 KEY _field_157 (_field_157),
536 KEY _field_158 (_field_158),
537 KEY _field_159 (_field_159),
538 KEY _field_160 (_field_160),
539 KEY _field_161 (_field_161)
541 INSERT INTO t5 VALUES (1,0,
'tomato',
'',
'',
'',
'',
'');
542 INSERT INTO t5 VALUES (2,0,
'cilantro',
'',
'',
'',
'',
'');
545 seq_0_id bigint(21) DEFAULT
'0' NOT NULL,
546 seq_1_id bigint(21) DEFAULT
'0' NOT NULL,
547 PRIMARY
KEY (seq_0_id,seq_1_id)
549 INSERT INTO t6 VALUES (1,1);
550 INSERT INTO t6 VALUES (1,2);
551 INSERT INTO t6 VALUES (2,2);
554 t7_id bigint(21) NOT NULL auto_increment,
555 _field_143 tinyint(4),
556 _field_165 varchar(32),
557 _field_166 smallint(6) DEFAULT
'0' NOT NULL,
559 KEY _field_166 (_field_166)
561 INSERT INTO t7 VALUES (1,0,
'High',1);
562 INSERT INTO t7 VALUES (2,0,
'Medium',2);
563 INSERT INTO t7 VALUES (3,0,
'Low',3);
565 select
replace(t3._field_140,
"\r",
"^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156),
replace(min(t3._field_140),
"\r",
"^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1)
group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
566 select * from information_schema.optimizer_trace;
567 drop
table t1,t2,t3,t4,t5,t6,t7;
570 --echo # Tracing of
ORDER BY & GROUP BY simplification.
573 # this is originally the testcase for
574 # Bug#12699645 SELECT SUM() + STRAIGHT_JOIN QUERY MISSES ROWS
576 pk INT, col_int_key INT,
577 col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1)
579 INSERT INTO t1 VALUES
580 (10,7,
'v',
'v'),(11,0,
's',
's'),(12,9,
'l',
'l'),(13,3,
'y',
'y'),(14,4,
'c',
'c'),
581 (15,2,
'i',
'i'),(16,5,
'h',
'h'),(17,3,
'q',
'q'),(18,1,
'a',
'a'),(19,3,
'v',
'v'),
582 (20,6,
'u',
'u'),(21,7,
's',
's'),(22,5,
'y',
'y'),(23,1,
'z',
'z'),(24,204,
'h',
'h'),
583 (25,224,
'p',
'p'),(26,9,
'e',
'e'),(27,5,
'i',
'i'),(28,0,
'y',
'y'),(29,3,
'w',
'w');
586 pk INT, col_int_key INT,
587 col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1),
590 INSERT INTO t2 VALUES
591 (1,4,
'b',
'b'),(2,8,
'y',
'y'),(3,0,
'p',
'p'),(4,0,
'f',
'f'),(5,0,
'p',
'p'),
592 (6,7,
'd',
'd'),(7,7,
'f',
'f'),(8,5,
'j',
'j'),(9,3,
'e',
'e'),(10,188,
'u',
'u'),
593 (11,4,
'v',
'v'),(12,9,
'u',
'u'),(13,6,
'i',
'i'),(14,1,
'x',
'x'),(15,5,
'l',
'l'),
594 (16,6,
'q',
'q'),(17,2,
'n',
'n'),(18,4,
'r',
'r'),(19,231,
'c',
'c'),(20,4,
'h',
'h'),
595 (21,3,
'k',
'k'),(22,3,
't',
't'),(23,7,
't',
't'),(24,6,
'k',
'k'),(25,7,
'g',
'g'),
596 (26,9,
'z',
'z'),(27,4,
'n',
'n'),(28,4,
'j',
'j'),(29,2,
'l',
'l'),(30,1,
'd',
'd'),
597 (31,2,
't',
't'),(32,194,
'y',
'y'),(33,2,
'i',
'i'),(34,3,
'j',
'j'),(35,8,
'r',
'r'),
598 (36,4,
'b',
'b'),(37,9,
'o',
'o'),(38,4,
'k',
'k'),(39,5,
'a',
'a'),(40,5,
'f',
'f'),
599 (41,9,
't',
't'),(42,3,
'c',
'c'),(43,8,
'c',
'c'),(44,0,
'r',
'r'),(45,98,
'k',
'k'),
600 (46,3,
'l',
'l'),(47,1,
'o',
'o'),(48,0,
't',
't'),(49,189,
'v',
'v'),(50,8,
'x',
'x'),
601 (51,3,
'j',
'j'),(52,3,
'x',
'x'),(53,9,
'k',
'k'),(54,6,
'o',
'o'),(55,8,
'z',
'z'),
602 (56,3,
'n',
'n'),(57,9,
'c',
'c'),(58,5,
'd',
'd'),(59,9,
's',
's'),(60,2,
'j',
'j'),
603 (61,2,
'w',
'w'),(62,5,
'f',
'f'),(63,8,
'p',
'p'),(64,6,
'o',
'o'),(65,9,
'f',
'f'),
604 (66,0,
'x',
'x'),(67,3,
'q',
'q'),(68,6,
'g',
'g'),(69,5,
'x',
'x'),(70,8,
'p',
'p'),
605 (71,2,
'q',
'q'),(72,120,
'q',
'q'),(73,25,
'v',
'v'),(74,1,
'g',
'g'),(75,3,
'l',
'l'),
606 (76,1,
'w',
'w'),(77,3,
'h',
'h'),(78,153,
'c',
'c'),(79,5,
'o',
'o'),(80,9,
'o',
'o'),
607 (81,1,
'v',
'v'),(82,8,
'y',
'y'),(83,7,
'd',
'd'),(84,6,
'p',
'p'),(85,2,
'z',
'z'),
608 (86,4,
't',
't'),(87,7,
'b',
'b'),(88,3,
'y',
'y'),(89,8,
'k',
'k'),(90,4,
'c',
'c'),
609 (91,6,
'z',
'z'),(92,1,
't',
't'),(93,7,
'o',
'o'),(94,1,
'u',
'u'),(95,0,
't',
't'),
610 (96,2,
'k',
'k'),(97,7,
'u',
'u'),(98,2,
'b',
'b'),(99,1,
'm',
'm'),(100,5,
'o',
'o');
613 SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1
614 STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk
615 GROUP BY field2
ORDER BY alias1.col_int_key,alias2.pk ;
617 --replace_regex /(
"sort_buffer_size":) [0-9]+/\1
"NNN"/
618 SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
623 --echo #
Trace of
"condition on constant tables"
625 create
table t1(a
int) engine=myisam;
626 insert into t1 values(26);
627 create
table t2(b
int primary key, c
int) engine=myisam;
628 insert into t2 values(1,100),(2,200),(3,300);
629 select * from t1,t2 where t1.a+t2.c=cos(10) and t2.b=2;
630 SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
634 --echo #
Trace of non-
default db
636 create
table t1(a
int);
637 insert into t1 values(1),(2),(3);
638 create database mysqltest2;
639 create
table mysqltest2.t2(a
int);
640 insert into mysqltest2.t2 values(1),(2);
641 select * from t1,mysqltest2.t2;
642 SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
644 drop database mysqltest2;