Re: count(*) and bad design was: Experiences with extensibility - Mailing list pgsql-general

From Sim Zacks
Subject Re: count(*) and bad design was: Experiences with extensibility
Date
Msg-id fm2m51$kt9$1@news.hub.org
Whole thread Raw
In response to Re: count(*) and bad design was: Experiences with extensibility  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Responses Re: count(*) and bad design was: Experiences with extensibility
Re: count(*) and bad design was: Experiences with extensibility
List pgsql-general
Using count(*) is not bad design, though generally it makes sense to use it with
a where.

Saying using count(*) is bad design means that the only design that you can
visualize is the specific one that you are using.

There are tons of real world examples where you need count. That is why so many
people use it as a benchmark.

Obviously if you have an application where millions of rows are added and
subtracted every minute, then the value of count is kind of vague.

However, if you are querying a data warehouse that gets populated once a month,
then count has a huge value. You could use statistics in that case, but it is
much harder to join against other tables when you are using statistics. It is
also less intuitive then using the SQL standard for finding the number of rows.

Sim

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: quick question abt pg_dump and restore
Next
From: "Josh Harrison"
Date:
Subject: Re: quick question abt pg_dump and restore