Re: Database I/O and other performance questions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Database I/O and other performance questions.
Date: 2000-12-23 17:06:15
Message-ID: 24829.977591175@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my> writes:
> would/should select count(*) be slower than select
> count(averysmallcolumnmaybeboolean)

There is actually a semantic difference there, see
http://www.postgresql.org/devel-corner/docs/postgres/sql-expressions.htm#SYNTAX-AGGREGATES
count(*) means the count of selected rows, but count(foo) means the
number of selected rows where the variable or expression is not NULL.

count(*) should be a fraction faster, because it doesn't expend any
cycles to check whether the specific column is NULL. The "*" in this
syntax doesn't mean "all columns" the way it does in a select list,
it's just a dummy.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-12-23 17:13:31 Re: Performance and doing USENET style threaded messages
Previous Message Bruce Momjian 2000-12-23 14:23:49 Re: Database I/O and other performance questions.