Re: Counting unique rows as an aggregate.

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: r_musta <zepolen(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Counting unique rows as an aggregate.
Date: 2008-09-29 20:25:58
Message-ID: dcc563d10809291325o2a682636s95e4b8ac51ca02ae@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Sep 29, 2008 at 12:12 PM, r_musta <zepolen(at)gmail(dot)com> wrote:
> However, this is starting to become too slow (as there are about 10 of
> these queries), and therefore I need to write an aggregate function
> which lets me do:
>
>>SELECT count_unique(make), count_unique(color) from table WHERE >criteria<;
>
> After reading about aggregate functions, this should be possible, as
> long as I can use a dictionary/hashmap type for the state<STYPE>
> argument.

This might be a nice fit for materialized views. While they're not
built in, PostgreSQL's extensibility allows you to build them prettily
easily.

http://jonathangardner.net/tech/w/PostgreSQL/Materialized_Views

Jonathan Gardner's web page on it is fantastic.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message postgres Emanuel CALVO FRANCO 2008-09-29 21:27:51 Re: [HACKERS] PostgreSQL future ideas
Previous Message Scott Marlowe 2008-09-29 20:18:04 Re: database question