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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
c37bf3ff
Commit
c37bf3ff
authored
Nov 27, 2013
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
039bc612
96f8058a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
1 deletion
+101
-1
mysql-test/r/stat_tables.result
mysql-test/r/stat_tables.result
+36
-0
mysql-test/r/stat_tables_innodb.result
mysql-test/r/stat_tables_innodb.result
+36
-0
mysql-test/t/stat_tables.test
mysql-test/t/stat_tables.test
+28
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/stat_tables.result
View file @
c37bf3ff
...
...
@@ -381,3 +381,39 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-5204: invalid impossible where after reading const tables
# when use_stat_tables = 'preferably'
#
set use_stat_tables = 'preferably';
CREATE TABLE t1 (id int PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
CREATE TABLE t2 (name char(3)) ENGINE=MyISAM;
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status Table is already up to date
INSERT INTO t2 VALUES ('USA'),('AUS');
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id name
1 AUS
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id name
1 AUS
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
mysql-test/r/stat_tables_innodb.result
View file @
c37bf3ff
...
...
@@ -408,5 +408,41 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-5204: invalid impossible where after reading const tables
# when use_stat_tables = 'preferably'
#
set use_stat_tables = 'preferably';
CREATE TABLE t1 (id int PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
CREATE TABLE t2 (name char(3)) ENGINE=MyISAM;
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status Table is already up to date
INSERT INTO t2 VALUES ('USA'),('AUS');
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id name
1 AUS
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id name
1 AUS
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
mysql-test/t/stat_tables.test
View file @
c37bf3ff
...
...
@@ -205,3 +205,31 @@ DROP TABLE t1;
set
use_stat_tables
=@
save_use_stat_tables
;
--
echo
#
--
echo
# Bug mdev-5204: invalid impossible where after reading const tables
--
echo
# when use_stat_tables = 'preferably'
--
echo
#
set
use_stat_tables
=
'preferably'
;
CREATE
TABLE
t1
(
id
int
PRIMARY
KEY
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
ANALYZE
TABLE
t1
;
CREATE
TABLE
t2
(
name
char
(
3
))
ENGINE
=
MyISAM
;
ANALYZE
TABLE
t2
;
INSERT
INTO
t2
VALUES
(
'USA'
),(
'AUS'
);
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
WHERE
name
IN
(
'AUS'
,
'YEM'
)
AND
id
=
1
;
EXPLAIN
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
WHERE
name
IN
(
'AUS'
,
'YEM'
)
AND
id
=
1
;
ANALYZE
TABLE
t2
;
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
WHERE
name
IN
(
'AUS'
,
'YEM'
)
AND
id
=
1
;
EXPLAIN
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
WHERE
name
IN
(
'AUS'
,
'YEM'
)
AND
id
=
1
;
DROP
TABLE
t1
,
t2
;
set
use_stat_tables
=@
save_use_stat_tables
;
sql/sql_select.cc
View file @
c37bf3ff
...
...
@@ -3691,7 +3691,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
// All dep. must be constants
if
(
s
->
dependent
&
~
(
found_const_table_map
))
continue
;
if
(
table
->
stat_records
()
<=
1L
&&
if
(
table
->
file
->
stats
.
records
<=
1L
&&
(
table
->
file
->
ha_table_flags
()
&
HA_STATS_RECORDS_IS_EXACT
)
&&
!
table
->
pos_in_table_list
->
embedding
&&
!
((
outer_join
&
table
->
map
)
&&
...
...
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