polardbxengine/mysql-test/suite/secondary_engine/r/query_preparation_debug.result

197 lines
10 KiB
Plaintext

CREATE TABLE t(x INT) SECONDARY_ENGINE MOCK;
INSERT INTO t VALUES (1);
ALTER TABLE t SECONDARY_LOAD;
FLUSH STATUS;
PREPARE ps FROM 'SELECT * FROM t';
EXECUTE ps;
x
SHOW SESSION STATUS LIKE 'Secondary_engine_execution_count';
Variable_name Value
Secondary_engine_execution_count 1
FLUSH STATUS;
SET DEBUG = '+d,secondary_engine_mock_prepare_error';
EXECUTE ps;
x
1
SET DEBUG = '-d,secondary_engine_mock_prepare_error';
SHOW SESSION STATUS LIKE 'Secondary_engine_execution_count';
Variable_name Value
Secondary_engine_execution_count 0
FLUSH STATUS;
EXECUTE ps;
x
1
SHOW SESSION STATUS LIKE 'Secondary_engine_execution_count';
Variable_name Value
Secondary_engine_execution_count 0
DROP TABLE t;
#
# WL#12389: Add interface for optimizing queries in secondary engines
#
CREATE TABLE t1(x INT) SECONDARY_ENGINE MOCK;
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2(y INT) SECONDARY_ENGINE MOCK;
INSERT INTO t2 VALUES (3), (4), (5);
ALTER TABLE t1 SECONDARY_LOAD;
ALTER TABLE t2 SECONDARY_LOAD;
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
SET DEBUG = "+d,secondary_engine_mock_optimize_error";
EXPLAIN SELECT * FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1`
EXPLAIN SELECT /*+ SET_VAR(use_secondary_engine = FORCED) */ x FROM t1;
ERROR HY000: Secondary engine operation failed. use_secondary_engine is FORCED but query could not be executed in secondary engine.
EXPLAIN SELECT (SELECT y FROM t2 WHERE y = 1) FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
Warnings:
Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`y` from `test`.`t2` where (`test`.`t2`.`y` = 1)) AS `(SELECT y FROM t2 WHERE y = 1)` from `test`.`t1`
EXPLAIN SELECT * FROM t1 UNION ALL SELECT * FROM t2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
2 UNION t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`y` AS `y` from `test`.`t2`
EXPLAIN SELECT * FROM t1 UNION DISTINCT SELECT * FROM t2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
2 UNION t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
NULL UNION RESULT <union1,2> NULL ALL NULL NULL NULL NULL NULL NULL Using temporary
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`y` AS `y` from `test`.`t2`
SET DEBUG = "-d,secondary_engine_mock_optimize_error";
EXPLAIN SELECT * FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1`
EXPLAIN SELECT (SELECT y FROM t2 WHERE y = 1) FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using secondary engine MOCK
Warnings:
Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`y` from `test`.`t2` where (`test`.`t2`.`y` = 1)) AS `(SELECT y FROM t2 WHERE y = 1)` from `test`.`t1`
EXPLAIN SELECT * FROM t1 UNION ALL SELECT * FROM t2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
2 UNION t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`y` AS `y` from `test`.`t2`
EXPLAIN SELECT * FROM t1 UNION DISTINCT SELECT * FROM t2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
2 UNION t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using secondary engine MOCK
NULL UNION RESULT <union1,2> NULL ALL NULL NULL NULL NULL NULL NULL Using temporary
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`y` AS `y` from `test`.`t2`
DROP TABLE t1, t2;
CREATE TABLE t(x int) SECONDARY_ENGINE MOCK;
INSERT INTO t VALUES (1), (2), (3);
ALTER TABLE t SECONDARY_LOAD;
SET DEBUG_SYNC = 'before_mock_optimize SIGNAL mock WAIT_FOR continue';
SELECT * FROM t;
SET DEBUG_SYNC = 'now WAIT_FOR mock';
SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO = 'SELECT * FROM t' INTO @thread_id;
KILL QUERY @thread_id;
SET DEBUG_SYNC = 'now SIGNAL continue';
ERROR 70100: Query execution was interrupted
DROP TABLE t;
#
# Bug#29023387: GET PLAN COST FROM SECONDARY ENGINE
#
CREATE TABLE t1(x INT, y INT) SECONDARY_ENGINE MOCK;
CREATE TABLE t2(x INT, y INT) SECONDARY_ENGINE MOCK;
CREATE TABLE t3(x INT, y INT) SECONDARY_ENGINE MOCK;
INSERT INTO t1 VALUES (1, 2), (3, 4);
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t2 VALUES (1, 2), (3, 4);
INSERT INTO t2 SELECT * FROM t2;
INSERT INTO t3 VALUES (1, 2), (3, 4);
ALTER TABLE t1 SECONDARY_LOAD;
ALTER TABLE t2 SECONDARY_LOAD;
ALTER TABLE t3 SECONDARY_LOAD;
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
SET @@optimizer_trace='enabled=on';
EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 ON t2.x = t3.y;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y`,`test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`y` = `test`.`t2`.`x`)) where (`test`.`t1`.`x` = `test`.`t2`.`y`)
SELECT TRACE->'$**.secondary_engine_cost' FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
TRACE->'$**.secondary_engine_cost'
[9.1004, 5.9002]
SET @@optimizer_trace='enabled=off';
SET DEBUG = "+d,secondary_engine_mock_change_join_order";
EXPLAIN SELECT * FROM t1 AS X JOIN t2 ON X.x = t2.y LEFT JOIN t3 ON t2.x = t3.y;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK
1 SIMPLE X NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
EXPLAIN SELECT * FROM t1 JOIN t2 AS X ON t1.x = X.y LEFT JOIN t3 ON X.x = t3.y;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE X NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 AS X ON t2.x = X.y;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK
1 SIMPLE X NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop); Using secondary engine MOCK
SET DEBUG = "-d,secondary_engine_mock_change_join_order";
SET DEBUG = "+d,secondary_engine_mock_compare_cost_error";
EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 ON t2.x = t3.y;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop)
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop)
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y`,`test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`y` = `test`.`t2`.`x`)) where (`test`.`t1`.`x` = `test`.`t2`.`y`)
SET DEBUG = "-d,secondary_engine_mock_compare_cost_error";
DROP TABLE t1, t2, t3;
#
# Bug#29615190: SELECTS ON TABLES OFFLOADED TO SECONDARY ENGINE ARE
# WRITTEN TWICE TO THE MYSQLD GENERAL LOG
#
CREATE TABLE t(x INT) SECONDARY_ENGINE MOCK;
ALTER TABLE t SECONDARY_LOAD;
SET @saved_general_log = @@global.general_log;
SET @saved_log_output = @@global.log_output;
SET GLOBAL general_log = 1;
SET GLOBAL log_output = 'table';
SET DEBUG = '+d,secondary_engine_mock_optimize_error';
TRUNCATE TABLE mysql.general_log;
SELECT * FROM t;
x
statement_count
1
TRUNCATE TABLE mysql.general_log;
PREPARE ps FROM 'SELECT * FROM t';
SELECT COUNT(*) FROM mysql.general_log WHERE argument = 'SELECT * FROM t';
COUNT(*)
1
EXECUTE ps;
x
SELECT COUNT(*) FROM mysql.general_log WHERE argument = 'SELECT * FROM t';
COUNT(*)
2
DROP PREPARE ps;
SET GLOBAL general_log = @saved_general_log;
SET GLOBAL log_output = @saved_log_output;
SET DEBUG = '-d,secondary_engine_mock_optimize_error';
TRUNCATE TABLE mysql.general_log;
DROP TABLE t;