Rewriting using rules for performance

From: Matthew Wakeling
Subject: Rewriting using rules for performance
Date: ,
Msg-id: alpine.DEB.2.00.0904031413560.21772@aragorn.flymine.org
(view: Whole thread, Raw)
Responses: Re: Rewriting using rules for performance  (Robert Haas)
Re: Rewriting using rules for performance  (Merlin Moncure)
List: pgsql-performance

Tree view

Rewriting using rules for performance  (Matthew Wakeling, )
 Re: Rewriting using rules for performance  (Robert Haas, )
  Re: Rewriting using rules for performance  (Matthew Wakeling, )
 Re: Rewriting using rules for performance  (Merlin Moncure, )
  Re: Rewriting using rules for performance  (Merlin Moncure, )

So, I have a view. The query that the view uses can be written two
different ways, to use two different indexes. Then I use the view in
another query, under some circumstances the first way will be quick, and
under other circumstances the second way will be quick.

What I want to know is, can I create a view that has both queries, and
allows the planner to choose which one to use? The documentation seems to
say so in http://www.postgresql.org/docs/8.3/interactive/querytree.html
(the rule system "creates zero or more query trees as result"), but
doesn't say how one would do it.

Matthew

--
 I have an inferiority complex. But it's not a very good one.


pgsql-performance by date:

From: Nathan Boley
Date:
Subject: Re: plpgsql arrays
From: David Kerr
Date:
Subject: Question on pgbench output