Re: Best way to get all different values in a column

From: mark(at)mark(dot)mielke(dot)cc
To: ext-christian(dot)roche(at)nokia(dot)com
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Best way to get all different values in a column
Date: 2005-10-14 16:38:19
Message-ID: 20051014163819.GA26955@mark.mielke.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Oct 14, 2005 at 06:02:56PM +0200, ext-christian(dot)roche(at)nokia(dot)com wrote:
> Does anyone here know what is the most efficient way to list all
> different values of a given column with low cardinality ? For instance
> I have a table with columns DAY, NAME, ID, etc. The table is updated
> about each week with thousands of records with the same (current) date.
> Now I would like to list all values for DAY, only if possible without
> scanning all the table each time I submit the request.
> I can think of:
> ...
> Solution 6: Store the values in a separate table, recreated each time
> TABLE is updated.

I've found a variant on 6 to work well for this problem domain.

Why not insert into the separate table, when you insert into the table?
Either as a trigger, or in your application.

Cheers,
mark

--
mark(at)mielke(dot)cc / markm(at)ncf(dot)ca / markm(at)nortel(dot)com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada

One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...

http://mark.mielke.cc/

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Steve Atkins 2005-10-14 17:04:24 Re: Best way to get all different values in a column
Previous Message ext-christian.roche 2005-10-14 16:02:56 Best way to get all different values in a column