Well, this was just a suggestion to make my queries run fast. I didn't
quite understand the difference between the two, so I thought I'd ask.
Thanx for clearing that up for me.
Mike Diehl,
Network Monitoring Tool Devl.
Sandia National Laboratories.
(505) 284-3137
jdiehl@sandia.gov
> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: September 20, 2001 12:56 AM
> To: Diehl, Jeffrey
> Cc: 'Haller Christoph'; pgsql-sql@postgresql.org
> Subject: Re: [SQL] Out of free buffers... HELP!
>
>
> "Diehl, Jeffrey" <jdiehl@sandia.gov> writes:
> > Ok, can someone explain to me why this first query might
> run faster than the
> > second?
> > select src,dst,count(dst) from data;
> > select src,dst,count(*) from data;
>
> Hmm, I'd expect the second to be marginally faster. count(*)
> counts the
> number of rows matching the WHERE condition; count(foo) counts the
> number of rows matching the WHERE condition for which foo is not NULL.
> So count(foo) ought to involve a couple extra cycles to test for
> non-NULL-ness of the specified field. But it's hard to believe you
> could measure the difference --- what results are you getting?
>
> regards, tom lane
>