By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,525 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.

pull_up_subqueries question

P: n/a
Hi

I was looking at pull_up_subqueries
(backend/optimizer/prep/prepjointree.c 135) and I was wondering why the
recursive optimization is only done on subqueries that can be optimized.
As in, why isn't the code like:

if (rte->rtekind == RTE_SUBQUERY) {
subquery = copyObject(subquery);
if (subquery->hasSubLinks)
subquery->jointree->quals = pull_up_IN_clauses(subquery,
subquery->jointree->quals);
subquery->jointree = (FromExpr *)
pull_up_subqueries(subquery, (Node *) subquery->jointree,
false);
if (is_simple_subquery(subquery) &&
(!below_outer_join || has_nullable_targetlist(subquery)) &&
!contain_whole_tuple_var((Node *) parse, varno, 0))
{
//optimize the subquery up
}
}
--
Dennis

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dennis Haney <da**@diku.dk> writes:
I was looking at pull_up_subqueries
(backend/optimizer/prep/prepjointree.c 135) and I was wondering why the
recursive optimization is only done on subqueries that can be optimized.


Because it will be done when the subquery is planned (via recursion to
subquery_planner), if the subquery is left as a separate subquery.
The only reason pull_up_subqueries has to do this at all is that it has
already been done to the rest of the upper query, and so we would miss
doing it to the pulled-up part of the tree if we didn't do it here.
Compare the order of operations in subquery_planner.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.