Re: Surprising benchmark count(1) vs. count(*)

From: Adam Brusselback <adambrusselback(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Surprising benchmark count(1) vs. count(*)
Date: 2019-09-19 20:38:33
Message-ID: CAMjNa7ftSKUFp4SO07ctTqBsQ5s7TjA89UFe_j1LON82b-oN0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I will say I've seen count(1) in the wild a ton, as well as at my own
company from developers who were used to it not making a difference.

There have been a couple queries in the hot path that I have had to changed
from count(1) to count(*) as part of performance tuning, but in general
it's not worth me worrying about. There are usually larger performance
issues to track down in complex queries.

It would be nice if Postgres optimized this case though because it is
really really common from what i've seen.

Thanks,
-Adam

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Luís Roberto Weck 2019-09-19 20:41:19 Re: Slow query on a one-tuple table
Previous Message Luís Roberto Weck 2019-09-19 20:24:39 Re: Slow query on a one-tuple table