Re: group by will not use an index?

From: Andrew Lazarus <andrew(at)pillette(dot)com>
To: tsuraan <tsuraan(at)gmail(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: group by will not use an index?
Date: 2007-01-10 01:41:27
Message-ID: 1961410679.20070109174127@pillette.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

For the reasons indicated (that is, MVCC), PG can not do a DISTINCT or the equivalent
GROUP BY from index values alone.

If this table is large, perhaps you could denormalize and maintain a
summary table with date (using truncation) and count, updated with
triggers on the original table. This table will presumably have a
small number of rows at the cost of doubling the times for updates,
inserts, and deletes.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2007-01-10 05:55:29 Re: Horribly slow query/ sequential scan
Previous Message Steinar H. Gunderson 2007-01-10 01:11:04 Re: group by will not use an index?