Re: Possible to improve query plan?

From: Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeremy Palmer <JPalmer(at)linz(dot)govt(dot)nz>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Possible to improve query plan?
Date: 2011-01-17 22:11:09
Message-ID: 4D34BE7D.3070007@vmsinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tom Lane wrote:
> If I'm not mistaken, that's a DB2-ish locution

It could also be a part of the Oracle vernacular. I've seen queries like
that running against Oracle RDBMS, too.

> for a query with DISTINCT
> ON, ie, you're looking for the row with highest _revision_created for
> each value of id. It might perform well on DB2, but it's going to
> mostly suck on Postgres --- we don't optimize window-function queries
> very much at all at the moment.
Hmmm, what optimizations do you have in mind? I thought that window
functions are just clever tricks with memory? Anything that can be
expected for 9.0x?

> Try writing it with DISTINCT ON instead
> of a window function, like so:
>
Wouldn't "distinct" necessarily bring about the sort/merge?

--

Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
http://www.vmsinfo.com
The Leader in Integrated Media Intelligence Solutions

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Fernando Hevia 2011-01-17 23:42:44 Re: Problem with query
Previous Message Pavel Stehule 2011-01-17 21:37:01 Re: Bad plan when join on function