Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

Jonathan Gardner's web page on it is fantastic.

In response to


pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group