Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mtr修改 #119

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 88 additions & 39 deletions mysql-test/r/explain_other.result-pq
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt'
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
1 SIMPLE <gather2> NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers)
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (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 2 100.00 NULL
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join)
1 SIMPLE <gather2> NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers)
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join)
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1'
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
Expand Down Expand Up @@ -100,34 +102,27 @@ EXPLAIN
"query_cost": "0.45"
},
"table": {
"table_name": "t1",
"table_name": "<gather2>",
"access_type": "ALL",
"rows_examined_per_scan": 2,
"rows_produced_per_join": 2,
"filtered": "100.00",
"parallel_execute": "4 workers",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "0.20",
"prefix_cost": "0.45",
"data_read_per_join": "16"
"data_read_per_join": "32"
},
"used_columns": [
"f1"
]
}
}
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)'
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "1.10"
},
"nested_loop": [
{
],
"query_block": {
"cost_info": {
"query_cost": "0.45"
},
"table": {
"select_id": 2,
"table_name": "t1",
"access_type": "ALL",
"rows_examined_per_scan": 2,
Expand All @@ -143,29 +138,83 @@ EXPLAIN
"f1"
]
}
}
}
}
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)'
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "1.10"
},
"table": {
"table_name": "<gather2>",
"access_type": "ALL",
"rows_examined_per_scan": 2,
"rows_produced_per_join": 2,
"filtered": "100.00",
"parallel_execute": "4 workers",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "0.20",
"prefix_cost": "0.45",
"data_read_per_join": "32"
},
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows_examined_per_scan": 2,
"rows_produced_per_join": 2,
"filtered": "50.00",
"using_where": true,
"first_match": "t1",
"using_join_buffer": "hash join",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "0.20",
"prefix_cost": "1.10",
"data_read_per_join": "16"
"used_columns": [
"f1"
],
"query_block": {
"cost_info": {
"query_cost": "1.10"
},
"nested_loop": [
{
"table": {
"select_id": 2,
"table_name": "t1",
"access_type": "ALL",
"rows_examined_per_scan": 2,
"rows_produced_per_join": 2,
"filtered": "100.00",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "0.20",
"prefix_cost": "0.45",
"data_read_per_join": "16"
},
"used_columns": [
"f1"
]
}
},
"used_columns": [
"f1"
]
}
{
"table": {
"select_id": 2,
"table_name": "t1",
"access_type": "ALL",
"rows_examined_per_scan": 2,
"rows_produced_per_join": 2,
"filtered": "50.00",
"using_where": true,
"first_match": "t1",
"using_join_buffer": "hash join",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "0.20",
"prefix_cost": "1.10",
"data_read_per_join": "16"
},
"used_columns": [
"f1"
]
}
}
]
}
]
}
}
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1'
Expand Down
77 changes: 77 additions & 0 deletions mysql-test/r/subselect_debug.result-pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d;
SET @orig_debug = @@debug;
SET SESSION debug="d,subselect_exec_fail";
SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1;
SUM(EXISTS(SELECT RAND() FROM t1))
0
SELECT REVERSE(EXISTS(SELECT RAND() FROM t1));
REVERSE(EXISTS(SELECT RAND() FROM t1))
0
SET SESSION debug=@orig_debug;
DROP TABLE t1;
#
# Bug#21383882 ASSERTION FAILED: 0 IN SELECT_LEX::PRINT()
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1),(1);
SELECT ((SELECT 1 FROM t1) IN (SELECT 1 FROM t1)) - (11111111111111111111);
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
#
# Bug#26679495: SIG 11 IN SUBSELECT_HASH_SJ_ENGINE::CLEANUP
#
CREATE TABLE t (x INT);
INSERT INTO t VALUES (1), (2), (3);
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
# The subquery should be materialized so that we
# use subselect_hash_sj_engine.
EXPLAIN SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t NULL ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary
Warnings:
Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` where <in_optimizer>(`test`.`t`.`x`,`test`.`t`.`x` in ( <materialize> (/* select#2 */ select count(0) from `test`.`t` group by `test`.`t`.`x` having true ), <primary_index_lookup>(`test`.`t`.`x` in <temporary table> on <auto_distinct_key> where ((`test`.`t`.`x` = `<materialized_subquery>`.`COUNT(*)`)))))
SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x);
x
1
# Execute the query with a simulated error in
# subselect_hash_sj_engine::setup().
SET DEBUG='+d,hash_semijoin_fail_in_setup';
SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x);
ERROR HY000: Unknown error
SET DEBUG='-d,hash_semijoin_fail_in_setup';
DROP TABLE t;
#
# Bug#26679983: SIG 11 IN MAKE_JOIN_READINFO|SQL/SQL_SELECT.CC
#
CREATE TABLE t (x INT);
INSERT INTO t VALUES (1), (2), (3);
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
# We want nested loop with duplicate weedout to reproduce the bug.
SET optimizer_switch = 'firstmatch=off,materialization=off';
EXPLAIN SELECT * FROM t WHERE x IN (SELECT x FROM t);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <gather2> NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers)
2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary
2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join)
Warnings:
Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` semi join (`test`.`t`) where (`test`.`t`.`x` = `test`.`t`.`x`)
SELECT * FROM t WHERE x IN (SELECT x FROM t);
x
1
2
3
# Execute the query with a simulated error in
# create_duplicate_weedout_tmp_table().
SET DEBUG='+d,create_duplicate_weedout_tmp_table_error';
SELECT * FROM t WHERE x IN (SELECT x FROM t);
ERROR HY000: Unknown error
SET DEBUG='-d,create_duplicate_weedout_tmp_table_error';
DROP TABLE t;
SET optimizer_switch = DEFAULT;
6 changes: 4 additions & 2 deletions mysql-test/suite/parallel_query/r/pq_variables.result-pq
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ Warnings:
Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1`
explain select/*+ PQ */ sum(id) 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 1024 100.00 NULL
1 SIMPLE <gather2> NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers)
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1`
explain select/*+ PQ(10) */ sum(id) 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 1024 100.00 NULL
1 SIMPLE <gather2> NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers)
2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1`
### test force_parallel query
Expand Down