performance of count(*)

From: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
To: "Postgresql (General)" <pgsql-general(at)postgresql(dot)org>
Subject: performance of count(*)
Date: 2011-05-06 18:45:23
Message-ID: 1962291A-1EE5-4DB4-9A8D-CC4CDE1FE097@elevated-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to optimize queries that deal with some aggregates regarding resource availability. My specific problem is, I think, very closely analogous to select count(*)... where...

I know roughly how to do it, aggregated stats table, triggers appending to it, occasional updates to coalesce entries. I'd just like to see an example to confirm my own plan and see if I'm missing any details.

I'm sure I've seen references to articles on ways to do this, but all google is getting me is generic complaints about count(*) performance and suggestions to use stats for estimated total rows in a table, nothing useful for this.

--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
http://www.elevated-dev.com/
(303) 722-0567 voice

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2011-05-06 19:39:55 Re: performance of count(*)
Previous Message Scott Marlowe 2011-05-06 17:02:12 Re: Growing a live database