Re: way to speed up a SELECT DISTINCT?

From: Peter Childs <blue(dot)dragon(at)blueyonder(dot)co(dot)uk>
To: Seth Ladd <seth(at)picklematrix(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: way to speed up a SELECT DISTINCT?
Date: 2003-10-10 11:17:10
Message-ID: Pine.LNX.4.44.0310101211270.5720-100000@RedDragon.Childs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, 10 Oct 2003, Seth Ladd wrote:

> >> Is there any way to speed this up, or is that DISTINCT going to keep
> >> hounding me?
> >>
> >> I checked the mailing list, and didn't see anything like this.
> >>
> >> Any tips or hints would be greatly appreciated. Thanks for your help!
> >> Seth
> >>
> >>
> > Try group by instead. I think this is an old bug its fixed in
> > 7.3.2 which I'm using.
> >
> > Peter Childs
> > `
> >
> >
> > peter(at)bernardo:express=# explain select distinct region from region;
> > QUERY PLAN
> > -----------------------------------------------------------------------
> > -----------------------
> > Unique (cost=0.00..4326.95 rows=9518 width=14)
> > -> Index Scan using regionview_region on region
> > (cost=0.00..4089.00
> > rows=95183 width=14)
> > (2 rows)
>
> Thanks for the tip, I'll give this a shot soon. I am curious, your
> example above does not use GROUP BY yet you have an INDEX SCAN. I am
> using a similar query, yet I get a full table scan. I wonder how they
> are different?
>
> I'll try the group by anyway.
>
Its a guess but ANALYSE might help. `

Peter Childs

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jeff 2003-10-10 12:08:37 Re: backup/restore - another area.
Previous Message Christopher Kings-Lynne 2003-10-10 11:05:27 Re: way to speed up a SELECT DISTINCT?