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

From r_musta
Subject Re: Counting unique rows as an aggregate.
Date
Msg-id 7c9ccfff-d4ce-4c2f-8258-8cf1ceb22a27@q9g2000hsb.googlegroups.com
Whole thread Raw
In response to Counting unique rows as an aggregate.  (r_musta <zepolen@gmail.com>)
List pgsql-general
On Sep 29, 11:25 pm, scott.marl...@gmail.com ("Scott Marlowe") 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

Materialized views won't work as the criteria used to narrow the
search is very arbritrary and rarely repeated, and as the count's
depend on the current result set, they would offer a miniscule
increase in speed, only as the row width would be a little smaller.

pgsql-general by date:

Previous
From: r_musta
Date:
Subject: Re: Counting unique rows as an aggregate.
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Free Cache Memory (Linux) and Postgresql