Re: On query rewrite

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 00:44:10
Message-ID: 20040528004410.GB9889@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 27, 2004 at 05:14:48PM -0700, Sailesh Krishnamurthy wrote:

> Are there any default query rewrite rules that kick in, in the absence
> of any user-defined RULE or VIEW ?
>
> Also, is there any place that lists any "interesting" query rewrite
> that PG does on queries for perf. improvement ?
>
> For instance, in the presence of a view or a subquery, does PG do a
> subquery to join transformation ?

Yes, there are transformations of this sort, but they are not called
query rewrite in the code's terminology, but "optimization" -- rewrite
(rules and views) happens to the parsed statement, and the optimizer
works on the output of rewriting. So actually the optimizations happen
whether there were or not rules or views.

The query's path is
SQL -> parse -> rewrite -> optimize -> execute

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El número de instalaciones de UNIX se ha elevado a 10,
y se espera que este número aumente" (UPM, 1972)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2004-05-28 01:05:52 Re: Win32, PITR, nested transactions, tablespaces
Previous Message Sailesh Krishnamurthy 2004-05-28 00:14:48 On query rewrite