Re: On query rewrite - Mailing list pgsql-hackers

From Tom Lane
Subject Re: On query rewrite
Date
Msg-id 27704.1085761794@sss.pgh.pa.us
Whole thread Raw
In response to Re: On query rewrite  (Sailesh Krishnamurthy <sailesh@cs.berkeley.edu>)
List pgsql-hackers
Sailesh Krishnamurthy <sailesh@cs.berkeley.edu> writes:
> Thanks again. To confirm the actual cost comparison with plan
> enumeration is a dynamic programming algorithm, is it not ?
> Selinger-style with 2-way join paths enumerated, then 3-way using the
> best 2-way etc. ? 

Correct.  For details see make_one_rel_by_joins in path/allpaths.c
and make_rels_by_joins in path/joinrels.c (dunno why what's basically
a single algorithm is split across two files).  There are some
heuristics involved concerning whether to consider clauseless joins,
so it's not totally trivial.

> BTW, do lots of people use the GEQO ? 

Only people writing queries that join more than a dozen or so tables.
GEQO is another thing we've improved (I think) recently, but it's still
pretty weak IMHO.  The algorithm is really designed to solve Traveling
Salesman problems, which bear only a crude resemblance to the behavior
of join problems.  I'd like to see a more principled solution in there
someday.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Matthew T. O'Connor"
Date:
Subject: pg_autovacuum Integration
Next
From: Alvaro Herrera
Date:
Subject: Re: SELECT * FROM LIMIT 1; is really slow