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
f34b4218
Commit
f34b4218
authored
May 10, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup, added comments.
parent
8d29fddb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
8 deletions
+46
-8
sql/item_subselect.cc
sql/item_subselect.cc
+41
-7
sql/opt_subselect.cc
sql/opt_subselect.cc
+2
-1
sql/sql_select.h
sql/sql_select.h
+3
-0
No files found.
sql/item_subselect.cc
View file @
f34b4218
...
...
@@ -4085,8 +4085,6 @@ void subselect_hash_sj_engine::cleanup()
result
->
cleanup
();
/* Resets the temp table as well. */
}
JOIN_TAB
*
first_top_level_tab
(
JOIN
*
join
,
enum
enum_with_const_tables
with_const
);
JOIN_TAB
*
next_top_level_tab
(
JOIN
*
join
,
JOIN_TAB
*
tab
);
/*
Get fanout produced by tables specified in the table_map
...
...
@@ -4215,6 +4213,24 @@ void check_out_index_stats(JOIN *join)
#endif
/*
Get an estimate of how many records will be produced after the GROUP BY
operation.
@param join Join we're operating on
@param join_op_rows How many records will be produced by the join
operations (this is what join optimizer produces)
@seealso
See also optimize_semijoin_nests(), grep for "Adjust output cardinality
estimates". Very similar code there that is not joined with this one
because we operate on different data structs and too much effort is
needed to abstract them out.
@return
Number of records we expect to get after the GROUP BY operation
*/
double
get_post_group_estimate
(
JOIN
*
join
,
double
join_op_rows
)
{
table_map
tables_in_group_list
=
table_map
(
0
);
...
...
@@ -4240,7 +4256,9 @@ double get_post_group_estimate(JOIN* join, double join_op_rows)
double
out_rows
;
out_rows
=
get_fanout_with_deps
(
join
,
tables_in_group_list
);
#if 0
/* The following will be needed when making use of index stats: */
/*
Also generate max. number of records for each of the tables mentioned
in the group-list. We'll use that a baseline number that we'll try to
...
...
@@ -4259,10 +4277,24 @@ double get_post_group_estimate(JOIN* join, double join_op_rows)
Try to bring down estimates using index statistics.
*/
//check_out_index_stats(join);
#endif
return
out_rows
;
}
/*
Optimize the underlying subselect's join
@param out_rows OUT How many records we expect to get in the
materialized table
@param cost OUT Cost to materialize the subquery
@return
0 OK
1 Fatal error
*/
int
subselect_hash_sj_engine
::
optimize
(
double
*
out_rows
,
double
*
cost
)
{
int
res
;
...
...
@@ -4271,7 +4303,8 @@ int subselect_hash_sj_engine::optimize(double *out_rows, double *cost)
JOIN
*
join
=
materialize_join
;
thd
->
lex
->
current_select
=
join
->
select_lex
;
res
=
join
->
optimize
();
if
((
res
=
join
->
optimize
()))
DBUG_RETURN
(
res
);
/* Calculate #rows and cost of join execution */
get_partial_join_cost
(
join
,
join
->
table_count
-
join
->
const_tables
,
...
...
@@ -4291,15 +4324,15 @@ int subselect_hash_sj_engine::optimize(double *out_rows, double *cost)
if
(
!
join
->
group_list
&&
!
join
->
group_optimized_away
&&
join
->
tmp_table_param
.
sum_func_count
)
{
DBUG_PRINT
(
"info"
,(
"Materialized join will have only 1 row (has "
"aggregates but no
t
GROUP BY"
));
DBUG_PRINT
(
"info"
,(
"Materialized join will have only 1 row (
it
has "
"aggregates but no GROUP BY"
));
*
out_rows
=
1
;
}
/* Now with grouping */
if
(
join
->
group_list
)
{
DBUG_PRINT
(
"info"
,(
"Materialized join has grouping, trying to estimate"
));
DBUG_PRINT
(
"info"
,(
"Materialized join has grouping, trying to estimate
it
"
));
double
output_rows
=
get_post_group_estimate
(
materialize_join
,
*
out_rows
);
DBUG_PRINT
(
"info"
,(
"Got value of %g"
,
output_rows
));
*
out_rows
=
output_rows
;
...
...
@@ -4308,6 +4341,7 @@ int subselect_hash_sj_engine::optimize(double *out_rows, double *cost)
DBUG_RETURN
(
res
);
}
/**
Execute a subquery IN predicate via materialization.
...
...
sql/opt_subselect.cc
View file @
f34b4218
...
...
@@ -1671,6 +1671,8 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
"oe IN (SELECT t.key ...)" it is trivial.
- Functional dependencies between the tables in the semi-join
nest (the payoff is probably less here?)
See also get_post_group_estimate().
*/
{
for
(
uint
i
=
0
;
i
<
join
->
const_tables
+
sjm
->
tables
;
i
++
)
...
...
@@ -3537,7 +3539,6 @@ int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
FALSE OK
TRUE Out of memory error
*/
JOIN_TAB
*
first_linear_tab
(
JOIN
*
join
,
enum
enum_with_const_tables
const_tbls
);
int
setup_semijoin_dups_elimination
(
JOIN
*
join
,
ulonglong
options
,
uint
no_jbuf_after
)
...
...
sql/sql_select.h
View file @
f34b4218
...
...
@@ -1076,6 +1076,9 @@ JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls);
JOIN_TAB
*
next_linear_tab
(
JOIN
*
join
,
JOIN_TAB
*
tab
,
enum
enum_with_bush_roots
include_bush_roots
);
JOIN_TAB
*
first_top_level_tab
(
JOIN
*
join
,
enum
enum_with_const_tables
with_const
);
JOIN_TAB
*
next_top_level_tab
(
JOIN
*
join
,
JOIN_TAB
*
tab
);
typedef
struct
st_select_check
{
uint
const_ref
,
reg_ref
;
}
SELECT_CHECK
;
...
...
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