Re: Speeding up select distinct

From: Rod Taylor <pg(at)rbt(dot)ca>
To: Laurent Martelli <laurent(at)aopsys(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Speeding up select distinct
Date: 2005-03-16 18:10:23
Message-ID: 1110996623.1132.244.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote:
> Consider this query:
>
> SELECT distinct owner from pictures;

The performance has nothing to do with the number of rows returned, but
rather the complexity of calculations and amount of data to sift through
in order to find it.

> Any ideas, apart from more or less manually maintaining a list of
> distinct owners in another table ?

This would be the proper thing to do, along with adding a foreign key
from pictures to the new owner structure for integrity enforcement.
--

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2005-03-16 18:19:09 Re: Speeding up select distinct
Previous Message Josh Berkus 2005-03-16 18:09:24 Re: multi-column index