WITH <table> SELECT * FROM function(<table>) WHERE etc

From: InterRob <rob(dot)marjot(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: WITH <table> SELECT * FROM function(<table>) WHERE etc
Date: 2009-09-29 10:00:19
Message-ID: 671e36b0909290300x51895efdw6790f458676a6a42@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear list,
Say, I wish to have a function returning a record, taking a row as
parameter. However, from a performance perspective, I wish to be able to
perform this query only on a subset by using a WHERE-clause.

I can only think of the following approach:

WITH ss AS ( SELECT * FROM my_table) SELECT * FROM my_function(ss) WHERE
ss.field1 > 100

Question is: does the optimizer apply this WHERE-clause to the WITH-SELECT
(resulting in "ss")?

Rob

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-09-29 10:53:14 Re: bulk inserts
Previous Message Scott Marlowe 2009-09-29 09:21:24 Re: Collation in ORDER BY not lexicographical