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
223f305c
Commit
223f305c
authored
Jun 27, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimization results (SCRUM) WL#902
parent
6f81b7e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+50
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+35
-0
No files found.
mysql-test/r/subselect.result
View file @
223f305c
...
@@ -1175,3 +1175,53 @@ SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1
...
@@ -1175,3 +1175,53 @@ SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1
'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
0
0
drop table t1;
drop table t1;
create table t1 (a int not null, b int, primary key (a));
create table t2 (a int not null, primary key (a));
create table t3 (a int not null, b int, primary key (a));
insert into t1 values (1,10), (2,20), (3,30), (4,40);
insert into t2 values (2), (3), (4), (5);
insert into t3 values (10,3), (20,4), (30,5);
select * from t2 where t2.a in (select a from t1);
a
2
3
4
explain select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
3
explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 Using where
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using where; Using index
drop table t1, t2, t3;
create table t1 (a int, b int, index a (a));
create table t2 (a int, index a (a));
create table t3 (a int, b int, index a (a));
insert into t1 values (1,10), (2,20), (3,30), (4,40);
insert into t2 values (2), (3), (4), (5);
insert into t3 values (10,3), (20,4), (30,5);
select * from t2 where t2.a in (select a from t1);
a
2
3
4
explain select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 ref a a 5 func 10 Using where; Using index
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
3
explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 ref a a 5 func 10 Using where
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 Using where; Using index
drop table t1, t2, t3;
mysql-test/t/subselect.test
View file @
223f305c
...
@@ -760,3 +760,38 @@ INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "
...
@@ -760,3 +760,38 @@ INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "
INSERT
INTO
t1
VALUES
(
"c373e9f5ad0791724315444553544200"
,
"AddDocumentTest"
,
"admin"
,
"2003-06-09 10:51:25"
,
"Movie Reviews"
,
"0"
,
"2003-06-09 10:51:25"
,
"admin"
,
"0"
,
"2f6161e879db43c1a5b82c21ddc49089"
,
"03eea05112b845949f3fd03278b5fe43"
,
NULL
);
INSERT
INTO
t1
VALUES
(
"c373e9f5ad0791724315444553544200"
,
"AddDocumentTest"
,
"admin"
,
"2003-06-09 10:51:25"
,
"Movie Reviews"
,
"0"
,
"2003-06-09 10:51:25"
,
"admin"
,
"0"
,
"2f6161e879db43c1a5b82c21ddc49089"
,
"03eea05112b845949f3fd03278b5fe43"
,
NULL
);
SELECT
'c373e9f5ad0791a0dab5444553544200'
IN
(
SELECT
t1
.
FOLDERID
FROM
t1
WHERE
t1
.
PARENTID
=
'2f6161e879db43c1a5b82c21ddc49089'
AND
t1
.
FOLDERNAME
=
'Level1'
);
SELECT
'c373e9f5ad0791a0dab5444553544200'
IN
(
SELECT
t1
.
FOLDERID
FROM
t1
WHERE
t1
.
PARENTID
=
'2f6161e879db43c1a5b82c21ddc49089'
AND
t1
.
FOLDERNAME
=
'Level1'
);
drop
table
t1
;
drop
table
t1
;
#
# IN subselect optimization test
#
create
table
t1
(
a
int
not
null
,
b
int
,
primary
key
(
a
));
create
table
t2
(
a
int
not
null
,
primary
key
(
a
));
create
table
t3
(
a
int
not
null
,
b
int
,
primary
key
(
a
));
insert
into
t1
values
(
1
,
10
),
(
2
,
20
),
(
3
,
30
),
(
4
,
40
);
insert
into
t2
values
(
2
),
(
3
),
(
4
),
(
5
);
insert
into
t3
values
(
10
,
3
),
(
20
,
4
),
(
30
,
5
);
select
*
from
t2
where
t2
.
a
in
(
select
a
from
t1
);
explain
select
*
from
t2
where
t2
.
a
in
(
select
a
from
t1
);
select
*
from
t2
where
t2
.
a
in
(
select
t1
.
a
from
t1
,
t3
where
t1
.
b
=
t3
.
a
);
explain
select
*
from
t2
where
t2
.
a
in
(
select
t1
.
a
from
t1
,
t3
where
t1
.
b
=
t3
.
a
);
drop
table
t1
,
t2
,
t3
;
create
table
t1
(
a
int
,
b
int
,
index
a
(
a
));
create
table
t2
(
a
int
,
index
a
(
a
));
create
table
t3
(
a
int
,
b
int
,
index
a
(
a
));
insert
into
t1
values
(
1
,
10
),
(
2
,
20
),
(
3
,
30
),
(
4
,
40
);
disable_query_log
;
# making table large enough
let
$
1
=
10000
;
while
(
$
1
)
{
eval
insert
into
t1
values
(
rand
()
*
100000
+
200
,
rand
()
*
100000
);
dec
$
1
;
}
enable_query_log
;
insert
into
t2
values
(
2
),
(
3
),
(
4
),
(
5
);
insert
into
t3
values
(
10
,
3
),
(
20
,
4
),
(
30
,
5
);
select
*
from
t2
where
t2
.
a
in
(
select
a
from
t1
);
explain
select
*
from
t2
where
t2
.
a
in
(
select
a
from
t1
);
select
*
from
t2
where
t2
.
a
in
(
select
t1
.
a
from
t1
,
t3
where
t1
.
b
=
t3
.
a
);
explain
select
*
from
t2
where
t2
.
a
in
(
select
t1
.
a
from
t1
,
t3
where
t1
.
b
=
t3
.
a
);
drop
table
t1
,
t2
,
t3
;
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