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
0a75fe85
Commit
0a75fe85
authored
Nov 17, 2002
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge::records_in_range and optimizer
parent
8796fc2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
4 deletions
+72
-4
mysql-test/r/merge.result
mysql-test/r/merge.result
+37
-2
mysql-test/t/merge.test
mysql-test/t/merge.test
+33
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-2
No files found.
mysql-test/r/merge.result
View file @
0a75fe85
...
@@ -35,10 +35,10 @@ insert into t1 select NULL,message from t2;
...
@@ -35,10 +35,10 @@ insert into t1 select NULL,message from t2;
create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2);
create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2);
explain select * from t3 where a < 10;
explain select * from t3 where a < 10;
table type possible_keys key key_len ref rows Extra
table type possible_keys key key_len ref rows Extra
t3 range a a 4 NULL 1
0
Using where
t3 range a a 4 NULL 1
8
Using where
explain select * from t3 where a > 10 and a < 20;
explain select * from t3 where a > 10 and a < 20;
table type possible_keys key key_len ref rows Extra
table type possible_keys key key_len ref rows Extra
t3 range a a 4 NULL 1
0
Using where
t3 range a a 4 NULL 1
6
Using where
select * from t3 where a = 10;
select * from t3 where a = 10;
a b
a b
10 Testing
10 Testing
...
@@ -561,3 +561,38 @@ a
...
@@ -561,3 +561,38 @@ a
1
1
2
2
drop table if exists t1, t2, t3, t4, t5, t6;
drop table if exists t1, t2, t3, t4, t5, t6;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
fileset_id tinyint(3) unsigned NOT NULL default '0',
file_code varchar(32) NOT NULL default '',
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (fileset_id,file_code),
KEY files (fileset_id,fileset_root_id)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1),
(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1),
(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1);
CREATE TABLE t2 (
fileset_id tinyint(3) unsigned NOT NULL default '0',
file_code varchar(32) NOT NULL default '',
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (fileset_id,file_code),
KEY files (fileset_id,fileset_root_id)
) TYPE=MRG_MyISAM UNION=(t1);
EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
table type possible_keys key key_len ref rows Extra
t2 range PRIMARY PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
table type possible_keys key key_len ref rows Extra
t2 range PRIMARY,files PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
table type possible_keys key key_len ref rows Extra
t1 range PRIMARY,files PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code = '0000000115' LIMIT 1;
table type possible_keys key key_len ref rows Extra
t2 const PRIMARY,files PRIMARY 33 const,const 1
DROP TABLE IF EXISTS t1, t2;
mysql-test/t/merge.test
View file @
0a75fe85
...
@@ -204,3 +204,36 @@ create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
...
@@ -204,3 +204,36 @@ create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
select
*
from
t6
;
select
*
from
t6
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
#
# testing merge::records_in_range and optimizer
#
DROP
TABLE
IF
EXISTS
t1
,
t2
;
CREATE
TABLE
t1
(
fileset_id
tinyint
(
3
)
unsigned
NOT
NULL
default
'0'
,
file_code
varchar
(
32
)
NOT
NULL
default
''
,
fileset_root_id
tinyint
(
3
)
unsigned
NOT
NULL
default
'0'
,
PRIMARY
KEY
(
fileset_id
,
file_code
),
KEY
files
(
fileset_id
,
fileset_root_id
)
)
TYPE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
2
,
'0000000111'
,
1
),
(
2
,
'0000000112'
,
1
),
(
2
,
'0000000113'
,
1
),
(
2
,
'0000000114'
,
1
),
(
2
,
'0000000115'
,
1
),
(
2
,
'0000000116'
,
1
),
(
2
,
'0000000117'
,
1
),
(
2
,
'0000000118'
,
1
),
(
2
,
'0000000119'
,
1
),
(
2
,
'0000000120'
,
1
);
CREATE
TABLE
t2
(
fileset_id
tinyint
(
3
)
unsigned
NOT
NULL
default
'0'
,
file_code
varchar
(
32
)
NOT
NULL
default
''
,
fileset_root_id
tinyint
(
3
)
unsigned
NOT
NULL
default
'0'
,
PRIMARY
KEY
(
fileset_id
,
file_code
),
KEY
files
(
fileset_id
,
fileset_root_id
)
)
TYPE
=
MRG_MyISAM
UNION
=
(
t1
);
EXPLAIN
SELECT
*
FROM
t2
IGNORE
INDEX
(
files
)
WHERE
fileset_id
=
2
AND
file_code
BETWEEN
'0000000115'
AND
'0000000120'
LIMIT
1
;
EXPLAIN
SELECT
*
FROM
t2
WHERE
fileset_id
=
2
AND
file_code
BETWEEN
'0000000115'
AND
'0000000120'
LIMIT
1
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
fileset_id
=
2
AND
file_code
BETWEEN
'0000000115'
AND
'0000000120'
LIMIT
1
;
EXPLAIN
SELECT
*
FROM
t2
WHERE
fileset_id
=
2
AND
file_code
=
'0000000115'
LIMIT
1
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
sql/sql_select.cc
View file @
0a75fe85
...
@@ -1219,7 +1219,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
...
@@ -1219,7 +1219,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
select
->
quick
=
0
;
select
->
quick
=
0
;
if
(
records
!=
HA_POS_ERROR
)
if
(
records
!=
HA_POS_ERROR
)
{
{
s
->
found_records
=
records
;
s
->
records
=
s
->
found_records
=
records
;
s
->
read_time
=
(
ha_rows
)
(
s
->
quick
?
s
->
quick
->
read_time
:
0.0
);
s
->
read_time
=
(
ha_rows
)
(
s
->
quick
?
s
->
quick
->
read_time
:
0.0
);
}
}
}
}
...
@@ -1944,7 +1944,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
...
@@ -1944,7 +1944,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
records
records
This gives the formula:
This gives the formula:
records= (x * (b-a) + a*c-b)/(c-1)
records= (x * (b-a) + a*c-b)/(c-1)
b = records matched by whole key
b = records matched by whole key
a = records matched by first key part (10% of all records?)
a = records matched by first key part (10% of all records?)
c = number of key parts in key
c = number of key parts in key
...
...
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