Skip site navigation (1) Skip section navigation (2)

Re: Help with unpredictable use of indexes on large tables...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "John D(dot) Burger" <john(at)mitre(dot)org>
Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with unpredictable use of indexes on large tables...
Date: 2006-04-29 19:23:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
"John D. Burger" <john(at)mitre(dot)org> writes:
> Tom Lane wrote:
>> Also I'd suggest trying
>> select year from [table] group by year
>> which is capable of using a hash aggregation approach; that will likely
>> beat either of these plans.

> Just out of curiosity, why doesn't the planner consider the same plan 
> for the OP's original query:
>    select distinct year from [table]
> Aren't these equivalent (except for the order)?

Mainly just that the DISTINCT code hasn't been rewritten to consider the
possibility.  The current implementation of DISTINCT is pretty tightly
intertwined with ORDER BY; I think it would take some serious hacking to
disentangle the two, and no one's got round to it.

			regards, tom lane

In response to

pgsql-general by date

Next:From: Dan BlackDate: 2006-04-29 19:49:00
Subject: how can i view deleted records?
Previous:From: Terry Lee TuckerDate: 2006-04-29 14:28:42
Subject: Re: file I/O in plpgsql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group