Re: postgres 9 query performance

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: yazan suleiman <yazan(dot)suleiman(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: postgres 9 query performance
Date: 2011-01-28 20:33:57
Message-ID: AANLkTikCey4d=--W=qKFw0AdkMaEALn1UQsuASac=h3U@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Jan 28, 2011 at 10:30 AM, yazan suleiman
<yazan(dot)suleiman(at)gmail(dot)com> wrote:
> I am evaluating postgres 9 to migrate away from Oracle.  The following query
> runs too slow, also please find the explain plan:
> ****************************************************************
> explain analyze select DISTINCT EVENT.ID, ORIGIN.ID AS
> ORIGINID,EVENT.PREFERRED_ORIGIN_ID AS PREFERRED_ORIGIN,
> EVENT.CONTRIBUTOR, ORIGIN.TIME, ORIGIN.LATITUDE, ORIGIN.LONGITUDE,
> ORIGIN.DEPTH,ORIGIN.EVTYPE,
> "Total runtime: 17799.669 ms"
> ****************************************************************
> This query runs in Oracle in 1 second while takes 16 seconds in postgres,
> The difference tells me that I am doing something wrong somewhere.  This is
> a new installation on a local Mac machine with 12G of RAM.

Try turning it into a group by instead of a distinct. i.e.

select a,b,c,d from xyz group by a,b,c,d

and see if it's faster. There is some poor performance on large data
sets for distinct. Don't know if they got fixed in 9.0 or not, if not
then definitely try a group by and see.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kenneth Marshall 2011-01-28 20:50:28 Re: postgres 9 query performance
Previous Message Scott Marlowe 2011-01-28 18:55:10 Re: How to best use 32 15k.7 300GB drives?