Re: On query rewrite - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: On query rewrite
Date
Msg-id 20040528004410.GB9889@dcc.uchile.cl
Whole thread Raw
In response to On query rewrite  (Sailesh Krishnamurthy <sailesh@cs.berkeley.edu>)
Responses Re: On query rewrite  (Sailesh Krishnamurthy <sailesh@cs.berkeley.edu>)
List 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)



pgsql-hackers by date:

Previous
From: Sailesh Krishnamurthy
Date:
Subject: On query rewrite
Next
From: pgsql@mohawksoft.com
Date:
Subject: Re: tablespaces and DB administration