hector Corrada Bravo <hcorrada@gmail.com> writes:
> 1) Regardless of the optimization problem, is the executor able to
> execute aggregate nodes within join trees (that is, not as the result
> of subqueries)?
Sure.
> 3) For debugging purposes: Has anyone figured out a way to feed
> hand-crafted plans to the executor? Setting up some of the data
> structures (PlannerInfo, target lists) etc. does not look trivial. By
> this I mean, beyond giving explicit join clauses in queries.
It's not really very practical --- the data structures are too complex
to create by hand in any reasonable way. You can probably test by
entering modified queries that do the aggregations in sub-selects,
though.
The most practical way to implement something like this is probably to
restructure the query during the "prep" stage, pushing the aggregates
down into sub-queries automatically. The 8.1 min/max optimization code
does something related, although I'll freely admit that's a bit of a hack.
regards, tom lane