From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | Sailesh Krishnamurthy <sailesh(at)cs(dot)berkeley(dot)edu> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: On query rewrite |
Date: | 2004-05-28 02:21:02 |
Message-ID: | 20040528022102.GA13614@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, May 27, 2004 at 06:27:47PM -0700, Sailesh Krishnamurthy wrote:
> >>>>> "Alvaro" == Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
>
> >> For instance, in the presence of a view or a subquery, does PG
> >> do a subquery to join transformation ?
>
> Alvaro> Yes, there are transformations of this sort, but they are
> Alvaro> not called query rewrite in the code's terminology, but
> Alvaro> "optimization" -- rewrite (rules and views) happens to the
> Alvaro> parsed statement, and the optimizer works on the output of
> Alvaro> rewriting. So actually the optimizations happen whether
> Alvaro> there were or not rules or views.
>
> Interesting .. so these are rule-based then ? Not cost-based ?
> I understand that there is a cost-based optimizer anyway that does the
> planning and selects the right plan .. but does this come _after_ all
> these transformations ? Or does it happen along with the
> transformations ?
No, there's no rules optimizer, only the cost-based one you already know
of.
> Alvaro> The query's path is SQL -> parse -> rewrite -> optimize ->
> Alvaro> execute
>
> Can you please point me to the code that indeed does such
> transformations ?
Sorry, I don't know the optimizer code. You can find a lot of detail in
backend/optimizer/README. Probably you want to look at what happens to
JOIN_IN nodes, for example, regarding the conversion of a
WHERE foo IN (SELECT bar FROM ...)
into some kind of join.
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La espina, desde que nace, ya pincha" (Proverbio africano)
From | Date | Subject | |
---|---|---|---|
Next Message | Sailesh Krishnamurthy | 2004-05-28 02:35:56 | Re: On query rewrite |
Previous Message | Erwin Brandstetter | 2004-05-28 02:18:13 | Dynamic fieldname with NEW structure in trigger function? |