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
f3bbd403
Commit
f3bbd403
authored
Apr 12, 2013
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-4389.
The selectivity of a range degenerated into a point never should be set to 0.
parent
549ada35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
0 deletions
+73
-0
mysql-test/r/selectivity.result
mysql-test/r/selectivity.result
+22
-0
mysql-test/r/selectivity_innodb.result
mysql-test/r/selectivity_innodb.result
+22
-0
mysql-test/t/selectivity.test
mysql-test/t/selectivity.test
+28
-0
sql/sql_statistics.cc
sql/sql_statistics.cc
+1
-0
No files found.
mysql-test/r/selectivity.result
View file @
f3bbd403
...
...
@@ -989,4 +989,26 @@ a b
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4389: join with degenerated range condition in WHERE
# when optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (f1 VARCHAR(1));
INSERT t1 VALUES ('p'),('q');
CREATE TABLE t2 (f2 VARCHAR(1));
INSERT INTO t2 VALUES
('o'),('v'),('f'),('f'),('e'),('l'),('j'),('p'),('r'),('j'),
('j'),('u'),('i'),('r'),('x'),('a'),('x'),('s');
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
FLUSH TABLES;
SET optimizer_use_condition_selectivity=3;
SELECT * FROM t1, t2 AS t2a, t2 AS t2b WHERE f1 <= 'a' AND t2a.f2 = f1;
f1 f2 f2
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
mysql-test/r/selectivity_innodb.result
View file @
f3bbd403
...
...
@@ -997,6 +997,28 @@ a b
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4389: join with degenerated range condition in WHERE
# when optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (f1 VARCHAR(1));
INSERT t1 VALUES ('p'),('q');
CREATE TABLE t2 (f2 VARCHAR(1));
INSERT INTO t2 VALUES
('o'),('v'),('f'),('f'),('e'),('l'),('j'),('p'),('r'),('j'),
('j'),('u'),('i'),('r'),('x'),('a'),('x'),('s');
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
FLUSH TABLES;
SET optimizer_use_condition_selectivity=3;
SELECT * FROM t1, t2 AS t2a, t2 AS t2b WHERE f1 <= 'a' AND t2a.f2 = f1;
f1 f2 f2
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
mysql-test/t/selectivity.test
View file @
f3bbd403
...
...
@@ -591,5 +591,33 @@ DROP TABLE t1,t2,t3;
set
use_stat_tables
=@
save_use_stat_tables
;
--
echo
#
--
echo
# Bug mdev-4389: join with degenerated range condition in WHERE
--
echo
# when optimizer_use_condition_selectivity=3
--
echo
#
set
use_stat_tables
=
PREFERABLY
;
CREATE
TABLE
t1
(
f1
VARCHAR
(
1
));
INSERT
t1
VALUES
(
'p'
),(
'q'
);
CREATE
TABLE
t2
(
f2
VARCHAR
(
1
));
INSERT
INTO
t2
VALUES
(
'o'
),(
'v'
),(
'f'
),(
'f'
),(
'e'
),(
'l'
),(
'j'
),(
'p'
),(
'r'
),(
'j'
),
(
'j'
),(
'u'
),(
'i'
),(
'r'
),(
'x'
),(
'a'
),(
'x'
),(
's'
);
ANALYZE
TABLE
t1
,
t2
;
FLUSH
TABLES
;
SET
optimizer_use_condition_selectivity
=
3
;
SELECT
*
FROM
t1
,
t2
AS
t2a
,
t2
AS
t2b
WHERE
f1
<=
'a'
AND
t2a
.
f2
=
f1
;
set
optimizer_use_condition_selectivity
=@
save_optimizer_use_condition_selectivity
;
DROP
TABLE
t1
,
t2
;
set
use_stat_tables
=@
save_use_stat_tables
;
set
use_stat_tables
=@
save_use_stat_tables
;
sql/sql_statistics.cc
View file @
f3bbd403
...
...
@@ -3417,6 +3417,7 @@ double get_column_range_cardinality(Field *field,
else
sel
=
hist
->
range_selectivity
(
min_mp_pos
,
max_mp_pos
);
res
=
col_non_nulls
*
sel
;
set_if_bigger
(
res
,
col_stats
->
get_avg_frequency
());
}
else
res
=
col_non_nulls
;
...
...
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