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
d92e84e0
Commit
d92e84e0
authored
Jan 18, 2012
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
88f451aa
40e4d09c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
5 deletions
+38
-5
mysql-test/r/derived_view.result
mysql-test/r/derived_view.result
+17
-0
mysql-test/r/view.result
mysql-test/r/view.result
+1
-1
mysql-test/suite/vcol/r/vcol_view_innodb.result
mysql-test/suite/vcol/r/vcol_view_innodb.result
+2
-2
mysql-test/suite/vcol/r/vcol_view_myisam.result
mysql-test/suite/vcol/r/vcol_view_myisam.result
+2
-2
mysql-test/t/derived_view.test
mysql-test/t/derived_view.test
+14
-0
sql/sql_derived.cc
sql/sql_derived.cc
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-0
No files found.
mysql-test/r/derived_view.result
View file @
d92e84e0
...
...
@@ -1889,5 +1889,22 @@ ORDER BY CONCAT(alias2.col_varchar_nokey);
col_varchar_key pk col_varchar_key col_varchar_nokey
set max_heap_table_size= @tmp_882994;
drop table t1,t2,t3;
#
# LP bug #917990: Bad estimate of #rows for derived table with LIMIT
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES
(8), (3), (4), (7), (9), (5), (1), (2);
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
a
8
3
4
EXPLAIN
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
2 DERIVED t1 ALL NULL NULL NULL NULL 8
DROP TABLE t1;
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;
mysql-test/r/view.result
View file @
d92e84e0
...
...
@@ -304,7 +304,7 @@ a+1
4
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
4
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
2
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
...
...
mysql-test/suite/vcol/r/vcol_view_innodb.result
View file @
d92e84e0
...
...
@@ -107,7 +107,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
4
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
2
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
...
...
@@ -119,7 +119,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
4
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
2
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
...
...
mysql-test/suite/vcol/r/vcol_view_myisam.result
View file @
d92e84e0
...
...
@@ -107,7 +107,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
4
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
2
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
...
...
@@ -119,7 +119,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
4
1 PRIMARY <derived2> ALL NULL NULL NULL NULL
2
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
...
...
mysql-test/t/derived_view.test
View file @
d92e84e0
...
...
@@ -1277,6 +1277,20 @@ ORDER BY CONCAT(alias2.col_varchar_nokey);
set
max_heap_table_size
=
@
tmp_882994
;
drop
table
t1
,
t2
,
t3
;
--
echo
#
--
echo
# LP bug #917990: Bad estimate of #rows for derived table with LIMIT
--
echo
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
8
),
(
3
),
(
4
),
(
7
),
(
9
),
(
5
),
(
1
),
(
2
);
SELECT
*
FROM
(
SELECT
*
FROM
t1
LIMIT
3
)
t
;
EXPLAIN
SELECT
*
FROM
(
SELECT
*
FROM
t1
LIMIT
3
)
t
;
DROP
TABLE
t1
;
# The following command must be the last one the file
set
optimizer_switch
=@
exit_optimizer_switch
;
set
join_cache_level
=@
exit_join_cache_level
;
sql/sql_derived.cc
View file @
d92e84e0
...
...
@@ -753,6 +753,7 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
if
(
!
derived
->
is_merged_derived
())
{
JOIN
*
join
=
first_select
->
join
;
unit
->
set_limit
(
first_select
);
unit
->
optimized
=
TRUE
;
if
((
res
=
join
->
optimize
()))
goto
err
;
...
...
sql/sql_select.cc
View file @
d92e84e0
...
...
@@ -3581,6 +3581,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
for
(
i
=
0
;
i
<
join
->
table_count
;
i
++
)
records
*=
join
->
best_positions
[
i
].
records_read
?
(
ha_rows
)
join
->
best_positions
[
i
].
records_read
:
1
;
set_if_smaller
(
records
,
unit
->
select_limit_cnt
);
join
->
select_lex
->
increase_derived_records
(
records
);
}
}
...
...
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