Re: Filter sequence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: André Volpato <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Filter sequence
Date: 2007-11-05 20:07:03
Message-ID: 26974.1194293223@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?ISO-8859-1?Q?Andr=E9_Volpato?= <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br> writes:
> select u2.cod, u2.name
> from
> (
> select u.cod, u.name
> from users u
> where age between 0 and 44 and sex='F'
> group by u.cod, u.name
> ) u2
> group by u2.cod, u2.name
> having
> getSalaryPeriod(1997,1999,u2.cod) > 1000

> I want the planner to filter the user age and sex (wich restricts the
> results and groups the user cod), and after that, run getSalaryPeriod
> ONLY in the results of the subquery u2. Instead, its filtering the age,
> sex and the salary in the same point :

The standard hack is to add "OFFSET 0" to the subquery --- this will
serve as an "optimization fence" without actually changing its results.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message andy 2007-11-05 20:09:12 Re: Is there a way to tell how far along a COPY is in the process?
Previous Message Tom Lane 2007-11-05 19:54:33 Re: running postgresql