Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2ae8dc24
Commit
2ae8dc24
authored
Mar 09, 2023
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted test results after rebase against 11.0.1
parent
12840543
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
3128 additions
and
1114 deletions
+3128
-1114
mysql-test/main/delete.result
mysql-test/main/delete.result
+2
-4
mysql-test/main/delete_single_to_multi.result
mysql-test/main/delete_single_to_multi.result
+1252
-239
mysql-test/main/delete_single_to_multi.test
mysql-test/main/delete_single_to_multi.test
+110
-86
mysql-test/main/derived_cond_pushdown.result
mysql-test/main/derived_cond_pushdown.result
+2
-13
mysql-test/main/log_state.result
mysql-test/main/log_state.result
+1
-1
mysql-test/main/multi_update.result
mysql-test/main/multi_update.result
+1
-0
mysql-test/main/myisam_explain_non_select_all.result
mysql-test/main/myisam_explain_non_select_all.result
+10
-14
mysql-test/main/opt_trace.result
mysql-test/main/opt_trace.result
+2
-2
mysql-test/main/subselect.result
mysql-test/main/subselect.result
+12
-0
mysql-test/main/subselect.test
mysql-test/main/subselect.test
+6
-0
mysql-test/main/subselect_no_exists_to_in.result
mysql-test/main/subselect_no_exists_to_in.result
+12
-0
mysql-test/main/subselect_no_mat.result
mysql-test/main/subselect_no_mat.result
+12
-0
mysql-test/main/subselect_no_opts.result
mysql-test/main/subselect_no_opts.result
+12
-0
mysql-test/main/subselect_no_scache.result
mysql-test/main/subselect_no_scache.result
+12
-0
mysql-test/main/subselect_no_semijoin.result
mysql-test/main/subselect_no_semijoin.result
+12
-0
mysql-test/main/update_single_to_multi.result
mysql-test/main/update_single_to_multi.result
+1574
-699
mysql-test/main/update_single_to_multi.test
mysql-test/main/update_single_to_multi.test
+93
-54
mysql-test/main/update_use_source.result
mysql-test/main/update_use_source.result
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+2
-1
No files found.
mysql-test/main/delete.result
View file @
2ae8dc24
...
...
@@ -583,8 +583,7 @@ explain delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
select *from t1;
...
...
@@ -600,8 +599,7 @@ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
order by c2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
order by c2;
...
...
mysql-test/main/delete_single_to_multi.result
View file @
2ae8dc24
...
...
@@ -2,10 +2,26 @@ DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
create index i_n_name on nation(n_name);
analyze table nation;
analyze table
nation, lineitem, customer, orders, part, supplier, partsupp, region
persistent for all;
Table Op Msg_type Msg_text
dbt3_s001.nation analyze status Engine-independent statistics collected
dbt3_s001.nation analyze status OK
dbt3_s001.lineitem analyze status Engine-independent statistics collected
dbt3_s001.lineitem analyze status OK
dbt3_s001.customer analyze status Engine-independent statistics collected
dbt3_s001.customer analyze status OK
dbt3_s001.orders analyze status Engine-independent statistics collected
dbt3_s001.orders analyze status OK
dbt3_s001.part analyze status Engine-independent statistics collected
dbt3_s001.part analyze status OK
dbt3_s001.supplier analyze status Engine-independent statistics collected
dbt3_s001.supplier analyze status OK
dbt3_s001.partsupp analyze status Engine-independent statistics collected
dbt3_s001.partsupp analyze status OK
dbt3_s001.region analyze status Engine-independent statistics collected
dbt3_s001.region analyze status OK
# Pullout
# =======
explain
...
...
@@ -15,8 +31,8 @@ where c_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
11
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1
(7%) Using where; Using rowid filter
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5
(7%) Using where; Using rowid filter
explain format=json
select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
...
...
@@ -26,6 +42,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.052271677,
"nested_loop": [
{
"table": {
...
...
@@ -36,7 +53,9 @@ EXPLAIN
"key_length": "26",
"used_key_parts": ["n_name"],
"ref": ["const"],
"loops": 1,
"rows": 1,
"cost": 0.002024411,
"filtered": 100,
"index_condition": "nation.n_name = 'PERU'"
}
...
...
@@ -50,7 +69,9 @@ EXPLAIN
"key_length": "5",
"used_key_parts": ["c_nationkey"],
"ref": ["dbt3_s001.nation.n_nationkey"],
"rows": 11,
"loops": 1,
"rows": 6,
"cost": 0.008193756,
"filtered": 100
}
},
...
...
@@ -71,7 +92,9 @@ EXPLAIN
"rows": 108,
"selectivity_pct": 7.2
},
"rows": 11,
"loops": 6,
"rows": 15,
"cost": 0.04205351,
"filtered": 7.199999809,
"attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
}
...
...
@@ -104,8 +127,8 @@ where c_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
11
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1
(7%) Using where; Using rowid filter
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5
(7%) Using where; Using rowid filter
explain format=json
delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
...
...
@@ -115,6 +138,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.052271677,
"nested_loop": [
{
"table": {
...
...
@@ -125,7 +149,9 @@ EXPLAIN
"key_length": "26",
"used_key_parts": ["n_name"],
"ref": ["const"],
"loops": 1,
"rows": 1,
"cost": 0.002024411,
"filtered": 100,
"index_condition": "nation.n_name = 'PERU'"
}
...
...
@@ -139,7 +165,9 @@ EXPLAIN
"key_length": "5",
"used_key_parts": ["c_nationkey"],
"ref": ["dbt3_s001.nation.n_nationkey"],
"rows": 11,
"loops": 1,
"rows": 6,
"cost": 0.008193756,
"filtered": 100
}
},
...
...
@@ -160,7 +188,9 @@ EXPLAIN
"rows": 108,
"selectivity_pct": 7.2
},
"rows": 11,
"loops": 6,
"rows": 15,
"cost": 0.04205351,
"filtered": 7.199999809,
"attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
}
...
...
@@ -200,9 +230,9 @@ s_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
2
1 PRIMARY part
supp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 16
1 PRIMARY part
eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
1
1 PRIMARY part
ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
1 PRIMARY part
supp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
(select p_partkey, s_suppkey from part, supplier
where p_retailprice between 901 and 910 and
...
...
@@ -230,9 +260,9 @@ s_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
2
1 PRIMARY part
supp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 16
1 PRIMARY part
eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
1
1 PRIMARY part
ALL PRIMARY NULL NULL NULL 200 Using where
1 PRIMARY part
supp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
delete from partsupp where (ps_partkey, ps_suppkey) in
(select p_partkey, s_suppkey from part, supplier
where p_retailprice between 901 and 910 and
...
...
@@ -267,9 +297,9 @@ where s_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
2
1 PRIMARY part
supp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 16
1 PRIMARY part
eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
1
1 PRIMARY part
ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
1 PRIMARY part
supp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
where p_retailprice between 901 and 910) and
ps_suppkey in (select s_suppkey from supplier
...
...
@@ -297,9 +327,9 @@ where s_nationkey in (select n_nationkey from nation
where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
2
1 PRIMARY part
supp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 16
1 PRIMARY part
eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey
1
1 PRIMARY part
ALL PRIMARY NULL NULL NULL 200 Using where
1 PRIMARY part
supp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
delete from partsupp where ps_partkey in (select p_partkey from part
where p_retailprice between 901 and 910) and
ps_suppkey in (select s_suppkey from supplier
...
...
@@ -344,11 +374,11 @@ where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 2
1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey 5 dbt3_s001.supplier.s_suppkey 100 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
1 PRIMARY orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (7%) Using where; Using rowid filter
1 PRIMARY customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
where o_custkey in
(select c_custkey from customer
...
...
@@ -401,11 +431,11 @@ where n_name='PERU'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 2
1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey 5 dbt3_s001.supplier.s_suppkey 100 Using where
1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
1 PRIMARY orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (7%) Using where; Using rowid filter
1 PRIMARY customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
delete from lineitem where l_orderkey in (select o_orderkey from orders
where o_custkey in
(select c_custkey from customer
...
...
@@ -466,9 +496,9 @@ and
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-10-09' and '1993-06-08');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
customer ALL PRIMARY,i_c_nationkey NULL NULL NULL 150
Using where
1 PRIMARY
nation eq_ref|filter PRIMARY,i_n_regionkey PRIMARY|i_n_regionkey 4|5 dbt3_s001.customer.c_nationkey 1 (40%) Using where; Using rowid filter
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1 (9%) Using where; FirstMatch(nation
); Using rowid filter
1 PRIMARY
nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25
Using where
1 PRIMARY
customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5 (9%) Using where; FirstMatch(customer
); Using rowid filter
explain format=json
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
where n_regionkey in (1,2))
...
...
@@ -479,37 +509,33 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.40015207,
"nested_loop": [
{
"table": {
"table_name": "
customer
",
"table_name": "
nation
",
"access_type": "ALL",
"possible_keys": ["PRIMARY", "i_c_nationkey"],
"rows": 150,
"filtered": 100,
"attached_condition": "customer.c_nationkey is not null"
"possible_keys": ["PRIMARY", "i_n_regionkey"],
"loops": 1,
"rows": 25,
"cost": 0.013945725,
"filtered": 40,
"attached_condition": "nation.n_regionkey in (1,2)"
}
},
{
"table": {
"table_name": "nation",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY", "i_n_regionkey"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["n_nationkey"],
"ref": ["dbt3_s001.customer.c_nationkey"],
"rowid_filter": {
"range": {
"key": "i_n_regionkey",
"used_key_parts": ["n_regionkey"]
},
"rows": 10,
"selectivity_pct": 40
},
"rows": 1,
"filtered": 40,
"attached_condition": "nation.n_regionkey in (1,2)"
"table_name": "customer",
"access_type": "ref",
"possible_keys": ["PRIMARY", "i_c_nationkey"],
"key": "i_c_nationkey",
"key_length": "5",
"used_key_parts": ["c_nationkey"],
"ref": ["dbt3_s001.nation.n_nationkey"],
"loops": 10,
"rows": 6,
"cost": 0.08009436,
"filtered": 100
}
},
{
...
...
@@ -529,10 +555,12 @@ EXPLAIN
"rows": 140,
"selectivity_pct": 9.333333333
},
"rows": 11,
"filtered": 9.333333015,
"loops": 60,
"rows": 15,
"cost": 0.306111985,
"filtered": 6.666666508,
"attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
"first_match": "
nation
"
"first_match": "
customer
"
}
}
]
...
...
@@ -589,9 +617,9 @@ and
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-10-09' and '1993-06-08');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
customer ALL PRIMARY,i_c_nationkey NULL NULL NULL 150
Using where
1 PRIMARY
nation eq_ref|filter PRIMARY,i_n_regionkey PRIMARY|i_n_regionkey 4|5 dbt3_s001.customer.c_nationkey 1 (40%) Using where; Using rowid filter
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1 (9%) Using where; FirstMatch(nation
); Using rowid filter
1 PRIMARY
nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25
Using where
1 PRIMARY
customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5 (9%) Using where; FirstMatch(customer
); Using rowid filter
explain format=json
delete from customer where c_nationkey in (select n_nationkey from nation
where n_regionkey in (1,2))
...
...
@@ -602,37 +630,33 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.40015207,
"nested_loop": [
{
"table": {
"table_name": "
customer
",
"table_name": "
nation
",
"access_type": "ALL",
"possible_keys": ["PRIMARY", "i_c_nationkey"],
"rows": 150,
"filtered": 100,
"attached_condition": "customer.c_nationkey is not null"
"possible_keys": ["PRIMARY", "i_n_regionkey"],
"loops": 1,
"rows": 25,
"cost": 0.013945725,
"filtered": 40,
"attached_condition": "nation.n_regionkey in (1,2)"
}
},
{
"table": {
"table_name": "nation",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY", "i_n_regionkey"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["n_nationkey"],
"ref": ["dbt3_s001.customer.c_nationkey"],
"rowid_filter": {
"range": {
"key": "i_n_regionkey",
"used_key_parts": ["n_regionkey"]
},
"rows": 10,
"selectivity_pct": 40
},
"rows": 1,
"filtered": 40,
"attached_condition": "nation.n_regionkey in (1,2)"
"table_name": "customer",
"access_type": "ref",
"possible_keys": ["PRIMARY", "i_c_nationkey"],
"key": "i_c_nationkey",
"key_length": "5",
"used_key_parts": ["c_nationkey"],
"ref": ["dbt3_s001.nation.n_nationkey"],
"loops": 10,
"rows": 6,
"cost": 0.08009436,
"filtered": 100
}
},
{
...
...
@@ -652,10 +676,12 @@ EXPLAIN
"rows": 140,
"selectivity_pct": 9.333333333
},
"rows": 11,
"filtered": 9.333333015,
"loops": 60,
"rows": 15,
"cost": 0.306111985,
"filtered": 6.666666508,
"attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
"first_match": "
nation
"
"first_match": "
customer
"
}
}
]
...
...
@@ -720,8 +746,8 @@ c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1993-01-08");
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
11
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1
(14%) Using where; FirstMatch(customer); Using rowid filter
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5
(14%) Using where; FirstMatch(customer); Using rowid filter
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
and
c_custkey in (select o_custkey from orders
...
...
@@ -745,8 +771,8 @@ c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1993-01-08");
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
11
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
1
(14%) Using where; FirstMatch(customer); Using rowid filter
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey
6
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5
(14%) Using where; FirstMatch(customer); Using rowid filter
delete from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
and
c_custkey in (select o_custkey from orders
...
...
@@ -771,27 +797,138 @@ Customer#000000133 2314.67
drop table t;
# Materialization
# ===============
set optimizer_switch='firstmatch=off';
explain
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
c_name c_acctbal
Customer#000000008 6819.74
Customer#000000014 5266.3
Customer#000000025 7133.7
Customer#000000035 1228.24
Customer#000000038 6345.11
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000067 8166.59
Customer#000000077 1738.87
Customer#000000094 5500.11
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000103 2757.45
Customer#000000106 3288.42
Customer#000000113 2912
Customer#000000121 6428.32
Customer#000000130 5073.58
Customer#000000133 2314.67
Customer#000000139 7897.78
Customer#000000142 2209.81
create table t as
select * from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
explain
delete from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
delete from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
c_name c_acctbal
insert into customer select * from t;
select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between "1992-01-09" and "1995-01-08");
c_name c_acctbal
Customer#000000008 6819.74
Customer#000000014 5266.3
Customer#000000025 7133.7
Customer#000000035 1228.24
Customer#000000038 6345.11
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000067 8166.59
Customer#000000077 1738.87
Customer#000000094 5500.11
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000103 2757.45
Customer#000000106 3288.42
Customer#000000113 2912
Customer#000000121 6428.32
Customer#000000130 5073.58
Customer#000000133 2314.67
Customer#000000139 7897.78
Customer#000000142 2209.81
drop table t;
set optimizer_switch='firstmatch=default';
explain
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
<subquery2> ALL distinct_key NULL NULL NULL 28
1 PRIMARY
customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey
1
2 MATERIALIZED orders
range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 28 Using index condition;
Using where
1 PRIMARY
customer ALL PRIMARY NULL NULL NULL 150
1 PRIMARY
<subquery2> eq_ref distinct_key distinct_key 4 func
1
2 MATERIALIZED orders
ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500
Using where
explain format=json
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.382051418,
"nested_loop": [
{
"table": {
"table_name": "
<subquery2>
",
"table_name": "
customer
",
"access_type": "ALL",
"possible_keys": ["PRIMARY"],
"loops": 1,
"rows": 150,
"cost": 0.03493875,
"filtered": 100
}
},
{
"table": {
"table_name": "<subquery2>",
"access_type": "eq_ref",
"possible_keys": ["distinct_key"],
"rows": 28,
"key": "distinct_key",
"key_length": "4",
"used_key_parts": ["o_custkey"],
"ref": ["func"],
"rows": 1,
"filtered": 100,
"materialized": {
"unique": 1,
...
...
@@ -801,89 +938,155 @@ EXPLAIN
{
"table": {
"table_name": "orders",
"access_type": "
range
",
"access_type": "
ALL
",
"possible_keys": ["i_o_orderdate", "i_o_custkey"],
"key": "i_o_orderdate",
"key_length": "4",
"used_key_parts": ["o_orderDATE"],
"rows": 28,
"filtered": 100,
"index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'",
"attached_condition": "orders.o_custkey is not null"
"loops": 1,
"rows": 1500,
"cost": 0.2532975,
"filtered": 16.13333321,
"attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
}
}
]
}
}
}
},
{
"table": {
"table_name": "customer",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["c_custkey"],
"ref": ["dbt3_s001.orders.o_custkey"],
"rows": 1,
"filtered": 100
}
}
]
}
}
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
create table t as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
explain
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
<subquery2> ALL distinct_key NULL NULL NULL 28
1 PRIMARY
customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey
1
2 MATERIALIZED orders
range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 28 Using index condition;
Using where
1 PRIMARY
customer ALL PRIMARY NULL NULL NULL 150
1 PRIMARY
<subquery2> eq_ref distinct_key distinct_key 4 func
1
2 MATERIALIZED orders
ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500
Using where
explain format=json
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.37364371,
"nested_loop": [
{
"table": {
"table_name": "
<subquery2>
",
"table_name": "
customer
",
"access_type": "ALL",
"possible_keys": ["PRIMARY"],
"loops": 1,
"rows": 150,
"cost": 0.026531042,
"filtered": 100
}
},
{
"table": {
"table_name": "<subquery2>",
"access_type": "eq_ref",
"possible_keys": ["distinct_key"],
"rows": 28,
"key": "distinct_key",
"key_length": "4",
"used_key_parts": ["o_custkey"],
"ref": ["func"],
"rows": 1,
"filtered": 100,
"materialized": {
"unique": 1,
...
...
@@ -893,71 +1096,121 @@ EXPLAIN
{
"table": {
"table_name": "orders",
"access_type": "
range
",
"access_type": "
ALL
",
"possible_keys": ["i_o_orderdate", "i_o_custkey"],
"key": "i_o_orderdate",
"key_length": "4",
"used_key_parts": ["o_orderDATE"],
"rows": 28,
"filtered": 100,
"index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'",
"attached_condition": "orders.o_custkey is not null"
"loops": 1,
"rows": 1500,
"cost": 0.2532975,
"filtered": 16.13333321,
"attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
}
}
]
}
}
}
},
{
"table": {
"table_name": "customer",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["c_custkey"],
"ref": ["dbt3_s001.orders.o_custkey"],
"rows": 1,
"filtered": 100
}
}
]
}
}
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
insert into customer select * from t;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000076 5745.33
Customer#000000091 4643.14
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
drop table t;
explain
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
...
...
@@ -1141,18 +1394,22 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.085533248,
"nested_loop": [
{
"table": {
"table_name": "<subquery2>",
"access_type": "ALL",
"possible_keys": ["distinct_key"],
"loops": 1,
"rows": 28,
"cost": 0.03691572,
"filtered": 100,
"materialized": {
"unique": 1,
"query_block": {
"select_id": 2,
"cost": 0.053826401,
"having_condition": "count(orders.o_custkey) > 1",
"temporary_table": {
"nested_loop": [
...
...
@@ -1164,7 +1421,9 @@ EXPLAIN
"key": "i_o_orderdate",
"key_length": "4",
"used_key_parts": ["o_orderDATE"],
"loops": 1,
"rows": 28,
"cost": 0.035889016,
"filtered": 100,
"index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
}
...
...
@@ -1184,7 +1443,9 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["c_custkey"],
"ref": ["<subquery2>.o_custkey"],
"loops": 28,
"rows": 1,
"cost": 0.048617528,
"filtered": 100
}
}
...
...
@@ -1220,18 +1481,22 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.054856476,
"nested_loop": [
{
"table": {
"table_name": "<subquery2>",
"access_type": "ALL",
"possible_keys": ["distinct_key"],
"loops": 1,
"rows": 28,
"cost": 0.03691572,
"filtered": 100,
"materialized": {
"unique": 1,
"query_block": {
"select_id": 2,
"cost": 0.053826401,
"having_condition": "count(orders.o_custkey) > 1",
"temporary_table": {
"nested_loop": [
...
...
@@ -1243,7 +1508,9 @@ EXPLAIN
"key": "i_o_orderdate",
"key_length": "4",
"used_key_parts": ["o_orderDATE"],
"loops": 1,
"rows": 28,
"cost": 0.035889016,
"filtered": 100,
"index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
}
...
...
@@ -1263,7 +1530,9 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["c_custkey"],
"ref": ["<subquery2>.o_custkey"],
"loops": 28,
"rows": 1,
"cost": 0.017940756,
"filtered": 100
}
}
...
...
@@ -1295,7 +1564,7 @@ where o_orderDATE between '1992-01-09' and '1993-03-08'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
2 MATERIALIZED orders
range i_o_orderdate i_o_orderdate 4 NULL 242 Using index condition
; Using temporary
2 MATERIALIZED orders
ALL i_o_orderdate NULL NULL NULL 1500 Using where
; Using temporary
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1993-03-08'
group by o_custkey having count(o_custkey) > 5);
...
...
@@ -1320,7 +1589,7 @@ where o_orderDATE between '1992-01-09' and '1993-03-08'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
2 MATERIALIZED orders
range i_o_orderdate i_o_orderdate 4 NULL 242 Using index condition
; Using temporary
2 MATERIALIZED orders
ALL i_o_orderdate NULL NULL NULL 1500 Using where
; Using temporary
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1993-03-08'
group by o_custkey having count(o_custkey) > 5);
...
...
@@ -1418,6 +1687,7 @@ drop table t,r;
deallocate prepare stmt;
# FirstMatch PS
# =============
set optimizer_switch='materialization=off';
prepare stmt from "
delete from customer where c_nationkey in (select n_nationkey from nation
where n_regionkey in (1,2))
...
...
@@ -1569,155 +1839,468 @@ Customer#000000139 7897.78
Customer#000000142 2209.81
drop table t,r;
deallocate prepare stmt;
set optimizer_switch='materialization=default';
# Materialization PS
# ==================
prepare stmt from "
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08') and c_name like ?;
where o_orderDATE between '1992-01-09' and '199
3
-03-08') and c_name like ?;
";
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
set @a1='Customer#%1_';
create table t as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08') and c_name like @a1;
where o_orderDATE between '1992-01-09' and '199
3
-03-08') and c_name like @a1;
execute stmt using @a1;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
insert into customer select * from t;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
set @a2='Customer#%3_';
create table r as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08') and c_name like @a2;
where o_orderDATE between '1992-01-09' and '199
3
-03-08') and c_name like @a2;
execute stmt using @a2;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
insert into customer select * from r;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
drop table t,r;
deallocate prepare stmt;
# Materialization SJM PS
# ======================
prepare stmt from "
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08') and c_acctbal between ? and ?;
where o_orderDATE between '1992-01-09' and '1992-03-08'
group by o_custkey having count(o_custkey) > 1) and c_acctbal between ? and ?;
";
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08'
...
...
@@ -1795,6 +2378,7 @@ o_orderkey o_totalprice
3142 16030.15
5095 184583.99
5121 150334.57
5382 138423.03
644 201268.06
737 12984.85
create table t as
...
...
@@ -1811,6 +2395,7 @@ o_orderkey o_totalprice
1729 12137.76
2880 145761.99
3142 16030.15
5382 138423.03
644 201268.06
737 12984.85
insert into orders select * from t;
...
...
@@ -1824,6 +2409,7 @@ o_orderkey o_totalprice
3142 16030.15
5095 184583.99
5121 150334.57
5382 138423.03
644 201268.06
737 12984.85
create table r as
...
...
@@ -1841,6 +2427,7 @@ o_orderkey o_totalprice
2880 145761.99
3142 16030.15
5121 150334.57
5382 138423.03
737 12984.85
insert into orders select * from r;
select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
...
...
@@ -1853,12 +2440,14 @@ o_orderkey o_totalprice
3142 16030.15
5095 184583.99
5121 150334.57
5382 138423.03
644 201268.06
737 12984.85
drop table t,r;
drop procedure p;
# FirstMatch SP
# =============
set optimizer_switch='materialization=off';
create procedure p(a int)
delete from customer where c_nationkey in (select n_nationkey from nation
where n_regionkey in (1,2))
...
...
@@ -1873,10 +2462,13 @@ where o_orderDATE between '1992-10-09' and '1993-06-08');
c_name c_acctbal
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000037 -917.75
Customer#000000040 1335.3
Customer#000000047 274.58
Customer#000000059 3458.6
Customer#000000061 1536.24
...
...
@@ -1913,8 +2505,11 @@ and
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-10-09' and '1993-06-08');
c_name c_acctbal
Customer#000000017 6.34
Customer#000000022 591.98
Customer#000000028 1007.18
Customer#000000037 -917.75
Customer#000000040 1335.3
Customer#000000047 274.58
Customer#000000059 3458.6
Customer#000000061 1536.24
...
...
@@ -1936,10 +2531,13 @@ where o_orderDATE between '1992-10-09' and '1993-06-08');
c_name c_acctbal
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000037 -917.75
Customer#000000040 1335.3
Customer#000000047 274.58
Customer#000000059 3458.6
Customer#000000061 1536.24
...
...
@@ -1976,8 +2574,11 @@ and
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-10-09' and '1993-06-08');
c_name c_acctbal
Customer#000000017 6.34
Customer#000000022 591.98
Customer#000000028 1007.18
Customer#000000037 -917.75
Customer#000000040 1335.3
Customer#000000047 274.58
Customer#000000061 1536.24
Customer#000000064 -646.64
...
...
@@ -1993,10 +2594,13 @@ where o_orderDATE between '1992-10-09' and '1993-06-08');
c_name c_acctbal
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000037 -917.75
Customer#000000040 1335.3
Customer#000000047 274.58
Customer#000000059 3458.6
Customer#000000061 1536.24
...
...
@@ -2022,81 +2626,304 @@ Customer#000000139 7897.78
Customer#000000142 2209.81
drop table t,r;
drop procedure p;
set optimizer_switch='materialization=default';
# Materialization SP
# ==================
create procedure p()
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
create table t as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
call p();
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
insert into customer select * from t;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
create table r as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
call p();
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
insert into customer select * from r;
select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name c_acctbal
Customer#000000001 711.56
Customer#000000002 121.65
Customer#000000005 794.47
Customer#000000007 9561.95
Customer#000000008 6819.74
Customer#000000010 2753.54
Customer#000000011 -272.6
Customer#000000013 3857.34
Customer#000000014 5266.3
Customer#000000016 4681.03
Customer#000000017 6.34
Customer#000000019 8914.71
Customer#000000022 591.98
Customer#000000023 3332.02
Customer#000000025 7133.7
Customer#000000028 1007.18
Customer#000000029 7618.27
Customer#000000031 5236.89
Customer#000000032 3471.53
Customer#000000034 8589.7
Customer#000000035 1228.24
Customer#000000037 -917.75
Customer#000000038 6345.11
Customer#000000040 1335.3
Customer#000000041 270.95
Customer#000000043 9904.28
Customer#000000044 7315.94
Customer#000000046 5744.59
Customer#000000047 274.58
Customer#000000049 4573.94
Customer#000000052 5630.28
Customer#000000053 4113.64
Customer#000000055 4572.11
Customer#000000056 6530.86
Customer#000000058 6478.46
Customer#000000059 3458.6
Customer#000000061 1536.24
Customer#000000062 595.61
Customer#000000064 -646.64
Customer#000000065 8795.16
Customer#000000067 8166.59
Customer#000000070 4867.52
Customer#000000071 -611.19
Customer#000000073 4288.5
Customer#000000074 2764.43
Customer#000000076 5745.33
Customer#000000079 5121.28
Customer#000000080 7383.53
Customer#000000082 9468.34
Customer#000000083 6463.51
Customer#000000085 3386.64
Customer#000000086 3306.32
Customer#000000088 8031.44
Customer#000000089 1530.76
Customer#000000091 4643.14
Customer#000000092 1182.91
Customer#000000094 5500.11
Customer#000000095 5327.38
Customer#000000097 2164.48
Customer#000000098 -551.37
Customer#000000100 9889.89
Customer#000000101 7470.96
Customer#000000103 2757.45
Customer#000000104 -588.38
Customer#000000106 3288.42
Customer#000000107 2514.15
Customer#000000109 -716.1
Customer#000000110 7462.99
Customer#000000112 2953.35
Customer#000000115 7508.92
Customer#000000116 8403.99
Customer#000000118 3582.37
Customer#000000121 6428.32
Customer#000000122 7865.46
Customer#000000127 9280.71
Customer#000000128 -986.96
Customer#000000130 5073.58
Customer#000000131 8595.53
Customer#000000133 2314.67
Customer#000000134 4608.9
Customer#000000136 -842.39
Customer#000000137 7838.3
Customer#000000139 7897.78
Customer#000000140 9963.15
Customer#000000142 2209.81
Customer#000000143 2186.5
Customer#000000145 9748.93
Customer#000000148 2135.6
Customer#000000149 8959.65
drop table t,r;
drop procedure p;
# Materialization SJM SP
...
...
@@ -2158,72 +2985,294 @@ drop procedure p;
# ====================
# Check for DELETE ... RETURNING with SJ subquery in WHERE
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name
Customer#000000001
Customer#000000002
Customer#000000005
Customer#000000007
Customer#000000008
Customer#000000010
Customer#000000011
Customer#000000013
Customer#000000014
Customer#000000016
Customer#000000017
Customer#000000019
Customer#000000022
Customer#000000023
Customer#000000025
Customer#000000028
Customer#000000029
Customer#000000031
Customer#000000032
Customer#000000034
Customer#000000035
Customer#000000037
Customer#000000038
Customer#000000040
Customer#000000041
Customer#000000043
Customer#000000044
Customer#000000046
Customer#000000047
Customer#000000049
Customer#000000052
Customer#000000053
Customer#000000055
Customer#000000056
Customer#000000058
Customer#000000059
Customer#000000061
Customer#000000062
Customer#000000064
Customer#000000065
Customer#000000067
Customer#000000070
Customer#000000071
Customer#000000073
Customer#000000074
Customer#000000076
Customer#000000079
Customer#000000080
Customer#000000082
Customer#000000083
Customer#000000085
Customer#000000086
Customer#000000088
Customer#000000089
Customer#000000091
Customer#000000092
Customer#000000094
Customer#000000095
Customer#000000097
Customer#000000098
Customer#000000100
Customer#000000101
Customer#000000103
Customer#000000104
Customer#000000106
Customer#000000107
Customer#000000109
Customer#000000110
Customer#000000112
Customer#000000115
Customer#000000116
Customer#000000118
Customer#000000121
Customer#000000122
Customer#000000127
Customer#000000128
Customer#000000130
Customer#000000131
Customer#000000133
Customer#000000134
Customer#000000136
Customer#000000137
Customer#000000139
Customer#000000140
Customer#000000142
Customer#000000143
Customer#000000145
Customer#000000148
Customer#000000149
create table t as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
explain
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08') returning c_name;
where o_orderDATE between '1992-01-09' and '199
3
-03-08') returning c_name;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer ALL NULL NULL NULL NULL 1
41
Using where
2 DEPENDENT SUBQUERY orders index_subquery
|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 func 175 (2%) Using where; Using rowid filter
1 PRIMARY customer ALL NULL NULL NULL NULL 1
50
Using where
2 DEPENDENT SUBQUERY orders index_subquery
i_o_orderdate,i_o_custkey i_o_custkey 5 func 15 Using where
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08') returning c_name;
where o_orderDATE between '1992-01-09' and '199
3
-03-08') returning c_name;
c_name
Customer#000000001
Customer#000000002
Customer#000000005
Customer#000000007
Customer#000000008
Customer#000000010
Customer#000000011
Customer#000000013
Customer#000000014
Customer#000000016
Customer#000000017
Customer#000000019
Customer#000000022
Customer#000000023
Customer#000000025
Customer#000000028
Customer#000000029
Customer#000000031
Customer#000000032
Customer#000000034
Customer#000000035
Customer#000000037
Customer#000000038
Customer#000000040
Customer#000000041
Customer#000000043
Customer#000000044
Customer#000000046
Customer#000000047
Customer#000000049
Customer#000000052
Customer#000000053
Customer#000000055
Customer#000000056
Customer#000000058
Customer#000000059
Customer#000000061
Customer#000000062
Customer#000000064
Customer#000000065
Customer#000000067
Customer#000000070
Customer#000000071
Customer#000000073
Customer#000000074
Customer#000000076
Customer#000000079
Customer#000000080
Customer#000000082
Customer#000000083
Customer#000000085
Customer#000000086
Customer#000000088
Customer#000000089
Customer#000000091
Customer#000000092
Customer#000000094
Customer#000000095
Customer#000000097
Customer#000000098
Customer#000000100
Customer#000000101
Customer#000000103
Customer#000000104
Customer#000000106
Customer#000000107
Customer#000000109
Customer#000000110
Customer#000000112
Customer#000000115
Customer#000000116
Customer#000000118
Customer#000000121
Customer#000000122
Customer#000000127
Customer#000000128
Customer#000000130
Customer#000000131
Customer#000000133
Customer#000000134
Customer#000000136
Customer#000000137
Customer#000000139
Customer#000000140
Customer#000000142
Customer#000000143
Customer#000000145
Customer#000000148
Customer#000000149
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name
insert into customer select * from t;
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '199
2
-03-08');
where o_orderDATE between '1992-01-09' and '199
3
-03-08');
c_name
Customer#000000001
Customer#000000002
Customer#000000005
Customer#000000007
Customer#000000008
Customer#000000010
Customer#000000011
Customer#000000013
Customer#000000014
Customer#000000016
Customer#000000017
Customer#000000019
Customer#000000022
Customer#000000023
Customer#000000025
Customer#000000028
Customer#000000029
Customer#000000031
Customer#000000032
Customer#000000034
Customer#000000035
Customer#000000037
Customer#000000038
Customer#000000040
Customer#000000041
Customer#000000043
Customer#000000044
Customer#000000046
Customer#000000047
Customer#000000049
Customer#000000052
Customer#000000053
Customer#000000055
Customer#000000056
Customer#000000058
Customer#000000059
Customer#000000061
Customer#000000062
Customer#000000064
Customer#000000065
Customer#000000067
Customer#000000070
Customer#000000071
Customer#000000073
Customer#000000074
Customer#000000076
Customer#000000079
Customer#000000080
Customer#000000082
Customer#000000083
Customer#000000085
Customer#000000086
Customer#000000088
Customer#000000089
Customer#000000091
Customer#000000092
Customer#000000094
Customer#000000095
Customer#000000097
Customer#000000098
Customer#000000100
Customer#000000101
Customer#000000103
Customer#000000104
Customer#000000106
Customer#000000107
Customer#000000109
Customer#000000110
Customer#000000112
Customer#000000115
Customer#000000116
Customer#000000118
Customer#000000121
Customer#000000122
Customer#000000127
Customer#000000128
Customer#000000130
Customer#000000131
Customer#000000133
Customer#000000134
Customer#000000136
Customer#000000137
Customer#000000139
Customer#000000140
Customer#000000142
Customer#000000143
Customer#000000145
Customer#000000148
Customer#000000149
drop table t;
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08'
...
...
@@ -2243,7 +3292,7 @@ delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08'
group by o_custkey having count(o_custkey) > 1) returning c_name;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer ALL NULL NULL NULL NULL 1
41
Using where
1 PRIMARY customer ALL NULL NULL NULL NULL 1
50
Using where
2 DEPENDENT SUBQUERY orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08'
...
...
@@ -2269,64 +3318,16 @@ Customer#000000037
Customer#000000056
Customer#000000118
drop table t;
# Check for DELETE ... RETURNING with SJ subquery in WHERE
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08');
c_name
Customer#000000013
Customer#000000016
Customer#000000025
Customer#000000032
Customer#000000037
Customer#000000038
Customer#000000052
Customer#000000056
Customer#000000065
Customer#000000076
Customer#000000091
Customer#000000115
Customer#000000116
Customer#000000118
Customer#000000140
create table t as
select * from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08');
explain
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08') returning c_name;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer ALL NULL NULL NULL NULL 141 Using where
2 DEPENDENT SUBQUERY orders index_subquery|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 func 175 (2%) Using where; Using rowid filter
delete from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08') returning c_name;
c_name
Customer#000000013
Customer#000000016
Customer#000000025
Customer#000000032
Customer#000000037
Customer#000000038
Customer#000000052
Customer#000000056
Customer#000000065
Customer#000000076
Customer#000000091
Customer#000000115
Customer#000000116
Customer#000000118
Customer#000000140
select c_name from customer where c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08');
c_name
insert into customer select * from t;
drop table t;
# Check for DELETE ... ORDER BY ...LIMIT with SJ subquery in WHERE
select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
o_orderkey o_totalprice
1221 117397.16
1344 43809.37
1856 189361.42
1925 146382.71
3139 40975.96
324 26868.85
4903 34363.63
5607 24660.06
...
...
@@ -2338,18 +3339,21 @@ where c_nationkey in (1,2))
order by o_totalprice limit 500;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY orders range i_o_orderdate i_o_orderdate 4 NULL 108 Using where; Using filesort
2 DEPENDENT SUBQUERY customer unique_subquery
|filter PRIMARY,i_c_nationkey PRIMARY|i_c_nationkey 4|5 func 1 (10%) Using where; Using rowid filter
2 DEPENDENT SUBQUERY customer unique_subquery
PRIMARY,i_c_nationkey PRIMARY 4 func 1 Using where
create table t as
select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
select o_orderkey, o_totalprice from t;
o_orderkey o_totalprice
1221 117397.16
324 26868.85
1856 189361.42
1221 117397.16
4903 34363.63
5607 24660.06
1344 43809.37
1925 146382.71
3139 40975.96
delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2))
...
...
@@ -2364,7 +3368,10 @@ o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
o_orderkey o_totalprice
1221 117397.16
1344 43809.37
1856 189361.42
1925 146382.71
3139 40975.96
324 26868.85
4903 34363.63
5607 24660.06
...
...
@@ -2375,19 +3382,22 @@ delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY customer range PRIMARY,i_c_nationkey i_c_nationkey 5 NULL 1
4
Using index condition
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
2
(7%) Using where; Using rowid filter
1 PRIMARY customer range PRIMARY,i_c_nationkey i_c_nationkey 5 NULL 1
3
Using index condition
1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 1
5
(7%) Using where; Using rowid filter
create table t as
select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
select o_orderkey, o_totalprice from t;
o_orderkey o_totalprice
1856 189361.42
324 26868.85
1221 117397.16
324 26868.85
1856 189361.42
4903 34363.63
5607 24660.06
1344 43809.37
1925 146382.71
3139 40975.96
delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
...
...
@@ -2401,7 +3411,10 @@ o_custkey in (select c_custkey from customer
where c_nationkey in (1,2));
o_orderkey o_totalprice
1221 117397.16
1344 43809.37
1856 189361.42
1925 146382.71
3139 40975.96
324 26868.85
4903 34363.63
5607 24660.06
...
...
mysql-test/main/delete_single_to_multi.test
View file @
2ae8dc24
...
...
@@ -15,7 +15,9 @@ use dbt3_s001;
--
enable_query_log
create
index
i_n_name
on
nation
(
n_name
);
analyze
table
nation
;
analyze
table
nation
,
lineitem
,
customer
,
orders
,
part
,
supplier
,
partsupp
,
region
persistent
for
all
;
--
echo
# Pullout
...
...
@@ -242,16 +244,18 @@ drop table t;
--
echo
# Materialization
--
echo
# ===============
set
optimizer_switch
=
'firstmatch=off'
;
let
$c7
=
c_nationkey
in
(
select
n_nationkey
from
nation
where
n_name
in
(
'JAPAN'
,
'INDONESIA'
,
'PERU'
,
'ARGENTINA'
))
and
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1992-03-08'
);
where
o_orderDATE
between
"1992-01-09"
and
"1995-01-08"
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c7
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c7
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
...
...
@@ -263,9 +267,6 @@ eval
explain
delete
from
customer
where
$c7
;
eval
explain
format
=
json
delete
from
customer
where
$c7
;
eval
delete
from
customer
where
$c7
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
...
...
@@ -276,14 +277,18 @@ eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
drop
table
t
;
set
optimizer_switch
=
'firstmatch=default'
;
let
$c8
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-0
6-09'
and
'1993-01
-08'
);
where
o_orderDATE
between
'1992-0
1-09'
and
'1993-03
-08'
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c8
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c8
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c8
;
...
...
@@ -295,6 +300,9 @@ eval
explain
delete
from
customer
where
$c8
;
eval
explain
format
=
json
delete
from
customer
where
$c8
;
eval
delete
from
customer
where
$c8
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c8
;
...
...
@@ -306,20 +314,13 @@ select c_name, c_acctbal from customer where $c8;
drop
table
t
;
--
echo
# Materialization SJM
--
echo
# ===================
let
$c9
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1992-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
1
);
where
o_orderDATE
between
'1992-06-09'
and
'1993-01-08'
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c9
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c9
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c9
;
...
...
@@ -331,9 +332,6 @@ eval
explain
delete
from
customer
where
$c9
;
eval
explain
format
=
json
delete
from
customer
where
$c9
;
eval
delete
from
customer
where
$c9
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c9
;
...
...
@@ -345,14 +343,20 @@ select c_name, c_acctbal from customer where $c9;
drop
table
t
;
--
echo
# Materialization SJM
--
echo
# ===================
let
$c10
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'199
3
-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
5
);
where
o_orderDATE
between
'1992-01-09'
and
'199
2
-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
1
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c10
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c10
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c10
;
...
...
@@ -364,6 +368,9 @@ eval
explain
delete
from
customer
where
$c10
;
eval
explain
format
=
json
delete
from
customer
where
$c10
;
eval
delete
from
customer
where
$c10
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c10
;
...
...
@@ -375,6 +382,36 @@ select c_name, c_acctbal from customer where $c10;
drop
table
t
;
let
$c11
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1993-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
5
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c11
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c11
;
eval
create
table
t
as
select
*
from
customer
where
$c11
;
eval
explain
delete
from
customer
where
$c11
;
eval
delete
from
customer
where
$c11
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c11
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c11
;
drop
table
t
;
--
echo
# Pullout PS
--
echo
# ==========
...
...
@@ -416,6 +453,8 @@ deallocate prepare stmt;
--
echo
# FirstMatch PS
--
echo
# =============
set
optimizer_switch
=
'materialization=off'
;
eval
prepare
stmt
from
"
delete from customer where
$c5
;
...
...
@@ -450,42 +489,43 @@ drop table t,r;
deallocate
prepare
stmt
;
set
optimizer_switch
=
'materialization=default'
;
--
echo
# Materialization PS
--
echo
# ==================
eval
prepare
stmt
from
"
delete from customer where
$c
7
and c_name like ?;
delete from customer where
$c
8
and c_name like ?;
"
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
set
@
a1
=
'Customer#%1_'
;
eval
create
table
t
as
select
*
from
customer
where
$c
7
and
c_name
like
@
a1
;
select
*
from
customer
where
$c
8
and
c_name
like
@
a1
;
execute
stmt
using
@
a1
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
set
@
a2
=
'Customer#%3_'
;
eval
create
table
r
as
select
*
from
customer
where
$c
7
and
c_name
like
@
a2
;
select
*
from
customer
where
$c
8
and
c_name
like
@
a2
;
execute
stmt
using
@
a2
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
insert
into
customer
select
*
from
r
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
drop
table
t
,
r
;
deallocate
prepare
stmt
;
...
...
@@ -496,38 +536,38 @@ deallocate prepare stmt;
eval
prepare
stmt
from
"
delete from customer where
$c
7
and c_acctbal between ? and ?;
delete from customer where
$c
10
and c_acctbal between ? and ?;
"
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
set
@
a1
=
3500
;
set
@
a2
=
4000
;
eval
create
table
t
as
select
*
from
customer
where
$c
9
and
c_acctbal
between
@
a1
and
@
a2
;
select
*
from
customer
where
$c
10
and
c_acctbal
between
@
a1
and
@
a2
;
execute
stmt
using
@
a1
,
@
a2
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
set
@
a3
=-
1000
;
set
@
a4
=
3500
;
eval
create
table
r
as
select
*
from
customer
where
$c
9
and
c_acctbal
between
@
a3
and
@
a4
;
select
*
from
customer
where
$c
10
and
c_acctbal
between
@
a3
and
@
a4
;
execute
stmt
using
@
a3
,
@
a4
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
insert
into
customer
select
*
from
r
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
drop
table
t
,
r
;
deallocate
prepare
stmt
;
...
...
@@ -573,6 +613,8 @@ drop procedure p;
--
echo
# FirstMatch SP
--
echo
# =============
set
optimizer_switch
=
'materialization=off'
;
eval
create
procedure
p
(
a
int
)
delete
from
customer
where
$c5
and
c_acctbal
>
a
;
...
...
@@ -606,39 +648,41 @@ drop table t,r;
drop
procedure
p
;
set
optimizer_switch
=
'materialization=default'
;
--
echo
# Materialization SP
--
echo
# ==================
eval
create
procedure
p
()
delete
from
customer
where
$c
7
;
delete
from
customer
where
$c
8
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
eval
create
table
t
as
select
*
from
customer
where
$c
7
;
select
*
from
customer
where
$c
8
;
call
p
();
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
eval
create
table
r
as
select
*
from
customer
where
$c
7
;
select
*
from
customer
where
$c
8
;
call
p
();
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
insert
into
customer
select
*
from
r
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
drop
table
t
,
r
;
drop
procedure
p
;
...
...
@@ -649,33 +693,33 @@ drop procedure p;
eval
create
procedure
p
()
delete
from
customer
where
$c
9
;
delete
from
customer
where
$c
10
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
create
table
t
as
select
*
from
customer
where
$c
9
;
select
*
from
customer
where
$c
10
;
call
p
();
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
create
table
r
as
select
*
from
customer
where
$c
9
;
select
*
from
customer
where
$c
10
;
call
p
();
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
insert
into
customer
select
*
from
r
;
--
sorted_result
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
drop
table
t
,
r
;
drop
procedure
p
;
...
...
@@ -687,64 +731,44 @@ drop procedure p;
--
sorted_result
eval
select
c_name
from
customer
where
$c
7
;
select
c_name
from
customer
where
$c
8
;
eval
create
table
t
as
select
*
from
customer
where
$c
7
;
select
*
from
customer
where
$c
8
;
eval
explain
delete
from
customer
where
$c
7
returning
c_name
;
delete
from
customer
where
$c
8
returning
c_name
;
--
sorted_result
eval
delete
from
customer
where
$c
7
returning
c_name
;
delete
from
customer
where
$c
8
returning
c_name
;
--
sorted_result
eval
select
c_name
from
customer
where
$c
7
;
select
c_name
from
customer
where
$c
8
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
from
customer
where
$c
7
;
select
c_name
from
customer
where
$c
8
;
drop
table
t
;
--
sorted_result
eval
select
c_name
from
customer
where
$c
9
;
select
c_name
from
customer
where
$c
10
;
eval
create
table
t
as
select
*
from
customer
where
$c
9
;
select
*
from
customer
where
$c
10
;
eval
explain
delete
from
customer
where
$c
9
returning
c_name
;
delete
from
customer
where
$c
10
returning
c_name
;
--
sorted_result
eval
delete
from
customer
where
$c
9
returning
c_name
;
delete
from
customer
where
$c
10
returning
c_name
;
--
sorted_result
eval
select
c_name
from
customer
where
$c
9
;
select
c_name
from
customer
where
$c
10
;
insert
into
customer
select
*
from
t
;
--
sorted_result
eval
select
c_name
from
customer
where
$c9
;
drop
table
t
;
--
echo
# Check for DELETE ... RETURNING with SJ subquery in WHERE
--
sorted_result
eval
select
c_name
from
customer
where
$c7
;
eval
create
table
t
as
select
*
from
customer
where
$c7
;
eval
explain
delete
from
customer
where
$c7
returning
c_name
;
--
sorted_result
eval
delete
from
customer
where
$c7
returning
c_name
;
--
sorted_result
eval
select
c_name
from
customer
where
$c7
;
insert
into
customer
select
*
from
t
;
select
c_name
from
customer
where
$c10
;
drop
table
t
;
--
echo
# Check for DELETE ... ORDER BY ...LIMIT with SJ subquery in WHERE
...
...
mysql-test/main/derived_cond_pushdown.result
View file @
2ae8dc24
...
...
@@ -13134,20 +13134,7 @@ EXPLAIN
"materialized": {
"query_block": {
"select_id": 3,
<<<<<<< 2ad65c4dbcb291867725d50d1f53c8da8549afb3
"cost": "COST_REPLACED",
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 2,
"cost": "COST_REPLACED",
"filtered": 100,
"attached_condition": "t1.f2 < 2"
}
=======
"filesort": {
"sort_key": "t1.f2",
"temporary_table": {
...
...
@@ -13156,7 +13143,9 @@ EXPLAIN
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 2,
"cost": "COST_REPLACED",
"filtered": 100,
"attached_condition": "t1.f2 < 2"
}
...
...
mysql-test/main/log_state.result
View file @
2ae8dc24
...
...
@@ -243,7 +243,7 @@ rows_examined sql_text
4 UPDATE t1 SET a=a+sleep(.02) WHERE a>2
8 UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC
1 UPDATE t2 set b=b+sleep(.02) limit 1
10
UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6
UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2
disconnect con2;
connection default;
...
...
mysql-test/main/multi_update.result
View file @
2ae8dc24
...
...
@@ -1270,6 +1270,7 @@ DROP TABLES t1, t2;
# End of 10.3 tests
#
# MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
#
create table t1 (c1 int, c2 int, c3 int, index idx(c2));
insert into t1 values
(1,1,1),(3,2,2),(1,3,3),
...
...
mysql-test/main/myisam_explain_non_select_all.result
View file @
2ae8dc24
...
...
@@ -218,16 +218,14 @@ INSERT INTO t2 VALUES (1), (2), (3);
#
EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
<subquery2> eq_ref distinct_key distinct_key 4 func 1
1 PRIMARY
t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY
<subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
1 PRIMARY
t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 Using where
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
...
...
@@ -248,9 +246,9 @@ Handler_read_key 4
Handler_read_rnd_next 5
# Status of testing query execution:
Variable_name Value
Handler_read_key
5
Handler_read_key
4
Handler_read_rnd 3
Handler_read_rnd_next
12
Handler_read_rnd_next
9
Handler_update 3
DROP TABLE t1, t2;
...
...
@@ -904,15 +902,13 @@ INSERT INTO t2 VALUES (1), (2), (3), (1000);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1)
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(t1)
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
...
...
@@ -933,8 +929,8 @@ Handler_read_key 4
Handler_read_rnd_next 9
# Status of testing query execution:
Variable_name Value
Handler_read_key
7
Handler_read_rnd_next
8
Handler_read_key
4
Handler_read_rnd_next
10
Handler_update 3
DROP TABLE t1, t2;
...
...
@@ -2828,14 +2824,14 @@ INSERT INTO t2 VALUES (1), (2), (3);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY <derived3>
ref key0 key0 5 test.t1.a 2 FirstMatch(t1)
1 PRIMARY <derived3>
eq_ref distinct_key distinct_key 5 test.t1.a 1
3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY <derived3>
ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY <derived3>
eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
# Status of EXPLAIN EXTENDED query
Variable_name Value
...
...
mysql-test/main/opt_trace.result
View file @
2ae8dc24
...
...
@@ -4495,7 +4495,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"rowid_filters": [
{
"key": "a",
"build_cost": 0.
174715752
,
"build_cost": 0.
001129926
,
"rows": 3
}
]
...
...
@@ -4570,7 +4570,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"rowid_filters": [
{
"key": "a",
"build_cost": 0.
174715752
,
"build_cost": 0.
001129926
,
"rows": 3
}
]
...
...
mysql-test/main/subselect.result
View file @
2ae8dc24
...
...
@@ -634,6 +634,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/subselect.test
View file @
2ae8dc24
...
...
@@ -387,6 +387,12 @@ insert into t2 values (1, 21),(2, 12),(3, 23);
select
*
from
t11
;
select
*
from
t12
;
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t12
where
t11
.
a
=
t12
.
a
);
select
*
from
t11
;
select
*
from
t12
;
delete
from
t11
;
delete
from
t12
;
insert
into
t11
values
(
0
,
10
),(
1
,
11
),(
2
,
12
);
insert
into
t12
values
(
33
,
10
),(
22
,
11
),(
2
,
12
);
--
error
ER_SUBQUERY_NO_1_ROW
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t2
);
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t2
where
t11
.
a
=
t2
.
a
);
...
...
mysql-test/main/subselect_no_exists_to_in.result
View file @
2ae8dc24
...
...
@@ -638,6 +638,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/subselect_no_mat.result
View file @
2ae8dc24
...
...
@@ -641,6 +641,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/subselect_no_opts.result
View file @
2ae8dc24
...
...
@@ -637,6 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/subselect_no_scache.result
View file @
2ae8dc24
...
...
@@ -640,6 +640,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/subselect_no_semijoin.result
View file @
2ae8dc24
...
...
@@ -637,6 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
...
...
mysql-test/main/update_single_to_multi.result
View file @
2ae8dc24
This source diff could not be displayed because it is too large. You can
view the blob
instead.
mysql-test/main/update_single_to_multi.test
View file @
2ae8dc24
...
...
@@ -15,8 +15,9 @@ use dbt3_s001;
--
enable_query_log
create
index
i_n_name
on
nation
(
n_name
);
analyze
table
nation
;
analyze
table
nation
,
lineitem
,
customer
,
orders
,
part
,
supplier
,
partsupp
,
region
persistent
for
all
;
--
echo
# Pullout
--
echo
# =======
...
...
@@ -209,117 +210,148 @@ select c_name, c_acctbal from customer where $c6;
--
echo
# Materialization
--
echo
# ===============
set
optimizer_switch
=
'firstmatch=off'
;
let
$c7
=
c_nationkey
in
(
select
n_nationkey
from
nation
where
n_name
in
(
'JAPAN'
,
'INDONESIA'
,
'PERU'
,
'ARGENTINA'
))
and
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1992-03-08'
);
where
o_orderDATE
between
"1992-01-09"
and
"1995-01-08"
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c7
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c7
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
eval
explain
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c7
;
update
customer
set
c_acctbal
=
c_acctbal
+
20
where
$c7
;
eval
explain
format
=
json
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c7
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c7
;
update
customer
set
c_acctbal
=
c_acctbal
+
20
where
$c7
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
eval
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c7
;
update
customer
set
c_acctbal
=
c_acctbal
-
20
where
$c7
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c7
;
set
optimizer_switch
=
'firstmatch=default'
;
let
$c8
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-0
6-09'
and
'1993-01
-08'
);
where
o_orderDATE
between
'1992-0
1-09'
and
'1993-03
-08'
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c8
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c8
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c8
;
eval
explain
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c8
;
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c8
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c8
;
explain
format
=
json
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c8
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c8
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c8
;
eval
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c8
;
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c8
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c8
;
let
$c9
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-06-09'
and
'1993-01-08'
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c9
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c9
;
eval
explain
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c9
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c9
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c9
;
eval
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c9
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c9
;
--
echo
# Materialization SJM
--
echo
# ===================
let
$c
9
=
let
$c
10
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1992-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
1
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
explain
format
=
json
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
explain
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
9
;
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
10
;
eval
explain
format
=
json
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
9
;
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
10
;
eval
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
9
;
update
customer
set
c_acctbal
=
c_acctbal
-
5
where
$c
10
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c
9
;
update
customer
set
c_acctbal
=
c_acctbal
+
5
where
$c
10
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
let
$c1
0
=
let
$c1
1
=
c_custkey
in
(
select
o_custkey
from
orders
where
o_orderDATE
between
'1992-01-09'
and
'1993-03-08'
group
by
o_custkey
having
count
(
o_custkey
)
>
5
);
eval
explain
select
c_name
,
c_acctbal
from
customer
where
$c1
0
;
select
c_name
,
c_acctbal
from
customer
where
$c1
1
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c1
0
;
select
c_name
,
c_acctbal
from
customer
where
$c1
1
;
eval
explain
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c1
0
;
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c1
1
;
eval
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c1
0
;
update
customer
set
c_acctbal
=
c_acctbal
-
1
where
$c1
1
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c1
0
;
select
c_name
,
c_acctbal
from
customer
where
$c1
1
;
eval
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c1
0
;
update
customer
set
c_acctbal
=
c_acctbal
+
1
where
$c1
1
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c1
0
;
select
c_name
,
c_acctbal
from
customer
where
$c1
1
;
--
echo
# Pullout PS
...
...
@@ -350,6 +382,8 @@ deallocate prepare stmt;
--
echo
# FirstMatch PS
--
echo
# =============
set
optimizer_switch
=
'materialization=off'
;
eval
prepare
stmt
from
"
update customer set c_acctbal = c_acctbal+? where
$c5
;
...
...
@@ -371,28 +405,29 @@ select c_name, c_acctbal from customer where $c5;
deallocate
prepare
stmt
;
set
optimizer_switch
=
'materialization=default'
;
--
echo
# Materialization PS
--
echo
# ==================
eval
prepare
stmt
from
"
update customer set c_acctbal = c_acctbal+? where
$c
7
;
update customer set c_acctbal = c_acctbal+? where
$c
8
;
"
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
set
@
a1
=
7
;
execute
stmt
using
@
a1
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
set
@
a2
=
3
;
execute
stmt
using
@
a2
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
execute
stmt
using
-
(
@
a1
+@
a2
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
deallocate
prepare
stmt
;
...
...
@@ -402,22 +437,22 @@ deallocate prepare stmt;
eval
prepare
stmt
from
"
update customer set c_acctbal = c_acctbal+? where
$c
9
;
update customer set c_acctbal = c_acctbal+? where
$c
10
;
"
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
set
@
a1
=-
2
;
execute
stmt
using
@
a1
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
set
@
a2
=-
1
;
execute
stmt
using
@
a2
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
execute
stmt
using
-
(
@
a1
+@
a2
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
deallocate
prepare
stmt
;
...
...
@@ -447,6 +482,8 @@ drop procedure p;
--
echo
# FirstMatch SP
--
echo
# =============
set
optimizer_switch
=
'materialization=off'
;
eval
create
procedure
p
(
d
int
)
update
customer
set
c_acctbal
=
c_acctbal
+
d
where
$c5
;
...
...
@@ -465,25 +502,27 @@ select c_name, c_acctbal from customer where $c5;
drop
procedure
p
;
set
optimizer_switch
=
'materialization=default'
;
--
echo
# Materialization SP
--
echo
# ==================
eval
create
procedure
p
(
d
int
)
update
customer
set
c_acctbal
=
c_acctbal
+
d
where
$c
7
;
update
customer
set
c_acctbal
=
c_acctbal
+
d
where
$c
8
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
call
p
(
3
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
call
p
(
7
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
call
p
(
-
(
3
+
7
));
eval
select
c_name
,
c_acctbal
from
customer
where
$c
7
;
select
c_name
,
c_acctbal
from
customer
where
$c
8
;
drop
procedure
p
;
...
...
@@ -493,19 +532,19 @@ drop procedure p;
eval
create
procedure
p
(
d
int
)
update
customer
set
c_acctbal
=
c_acctbal
+
d
where
$c
9
;
update
customer
set
c_acctbal
=
c_acctbal
+
d
where
$c
10
;
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
call
p
(
-
1
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
call
p
(
-
2
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
call
p
(
1
+
2
);
eval
select
c_name
,
c_acctbal
from
customer
where
$c
9
;
select
c_name
,
c_acctbal
from
customer
where
$c
10
;
drop
procedure
p
;
...
...
mysql-test/main/update_use_source.result
View file @
2ae8dc24
...
...
@@ -316,7 +316,7 @@ rollback;
#
explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 2 Using
where
1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 2 Using
index condition
1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 8 Using index; FirstMatch(t1)
start transaction;
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
...
...
sql/sql_select.cc
View file @
2ae8dc24
...
...
@@ -32592,7 +32592,8 @@ bool Sql_cmd_dml::execute_inner(THD *thd)
if (unlikely(thd->is_error()))
goto err;
join->exec();
if (join->exec())
goto err;
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment