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:41:04
Message-ID: 1110998464.1132.252.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 2005-03-16 at 19:31 +0100, Laurent Martelli wrote:
> >>>>> "Rod" == Rod Taylor <pg(at)rbt(dot)ca> writes:
>
> Rod> On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote:
> >> Consider this query:
> >>
> >> SELECT distinct owner from pictures;
>
> Rod> The performance has nothing to do with the number of rows
> Rod> returned, but rather the complexity of calculations and amount
> Rod> of data to sift through in order to find it.
>
> Yes, but I thought that an index might be able to know what distinct
> values there are and help optime that query very much.

The index does know. You just have to visit all of the pages within the
index to find out, which it does, and that's why you dropped 10ms.

But if you want a sub ms query, you're going to have to normalize the
structure.

--

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2005-03-16 18:56:07 Re: Speeding up select distinct
Previous Message Laurent Martelli 2005-03-16 18:38:30 Re: Speeding up select distinct