From: mark@mark.mielke.cc
To: ext-christian.roche@nokia.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Best way to get all different values in a column
Date: Fri, 14 Oct 2005 12:38:19 -0400
Message-ID: <20051014163819.GA26955@mark.mielke.cc> (raw)
In-Reply-To: <EA23CCFEC4F57A4D92C5B163C6946F1986C9BB@duebe101.NOE.Nokia.com>
References: <EA23CCFEC4F57A4D92C5B163C6946F1986C9BB@duebe101.NOE.Nokia.com>
On Fri, Oct 14, 2005 at 06:02:56PM +0200, ext-christian.roche@nokia.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@mielke.cc / markm@ncf.ca / markm@nortel.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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mark@mark.mielke.cc, ext-christian.roche@nokia.com
Subject: Re: Best way to get all different values in a column
In-Reply-To: <20051014163819.GA26955@mark.mielke.cc>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox