From: | bricklen <bricklen(at)gmail(dot)com> |
---|---|
To: | Christopher Jackson <crjackso(at)gmail(dot)com> |
Cc: | "pgsql-performance(at)postgresql(dot)org list" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Slow Count-Distinct Query |
Date: | 2014-04-02 00:34:09 |
Message-ID: | CAGrpgQ9ga0N0cF8+Z0ZW8t1mgS=3v1igVdaiciz-Q5Z7ddfOyA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Sun, Mar 30, 2014 at 12:45 PM, Christopher Jackson <crjackso(at)gmail(dot)com>wrote:
> Hi all,
>
> tl;dr - How can I speed up my count-distinct query?
>
Depending on how often you need to run that query and how important it is
to you, if you are willing to accept a performance hit on
INSERT/UPDATE/DELETE of the "participants" table, you could create a
summary table containing just the count of unique email addresses or the
list of unique email addresses populated via trigger on
INSERT/UPDATE/DELETE of the participants table. Another option is try out
the new Materialized views (
http://www.postgresql.org/docs/current/static/sql-creatematerializedview.html)
available in 9.3.
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Jackson | 2014-04-02 04:22:14 | Re: Slow Count-Distinct Query |
Previous Message | Andres Freund | 2014-04-01 22:16:53 | Re: Sudden crazy high CPU usage |