Re: Counting unique rows as an aggregate. - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Counting unique rows as an aggregate.
Date
Msg-id dcc563d10809291325o2a682636s95e4b8ac51ca02ae@mail.gmail.com
Whole thread Raw
In response to Counting unique rows as an aggregate.  (r_musta <zepolen@gmail.com>)
List pgsql-general
On Mon, Sep 29, 2008 at 12:12 PM, r_musta <zepolen@gmail.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.

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: database question
Next
From: "postgres Emanuel CALVO FRANCO"
Date:
Subject: Re: [HACKERS] PostgreSQL future ideas