On Wed, Dec 2, 2009 at 10:53 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Robert Haas <robertmh...@gmail.com> writes: >> Well, when I was testing, I believe I observed that an n-way join with >> 1 cross join was slower to plan than an n-way join with no cross >> joins. ISTM that it should actually be faster, because you should >> plan it like an (n-1)-way join and then do the cross join at the end. > > It's not entirely clear to me what case you're describing, but I wonder > whether this was a "flat" join problem or restricted by the collapse > limits.
Argh. I can't reproduce exactly what I thought I was seeing before. However, with the attached schema, geqo off, and the collapse thresholds set to 100, "explain select * from bar2_view" and "explain select * from bar3_view" have roughly the same run time. They are identical except that one of the join clauses has been omitted in the second case. One would think that the second case could be planned faster, if we plan to just leave the cross join to the end. (And in fact on my system if you remove bar8 from the second view entirely the plan time improves by a factor of six.) ...Robert
join2.sql
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers