Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAuWO-0001J2-Kw for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 11:22:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuWN-0005Us-Ci for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 11:22:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAuWN-0005Ub-2a for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 11:22:47 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAuWJ-0008KE-VW for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 11:22:46 +0000 Received: from [10.8.0.75] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPSA (Nemesis) id 1N2V8T-1i4cv80xCR-013wDh for ; Thu, 19 Sep 2019 13:22:41 +0200 Subject: Re: Surprising benchmark count(1) vs. count(*) References: From: Thomas Kellerer To: pgsql-performance@lists.postgresql.org Message-ID: <35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net> Date: Thu, 19 Sep 2019 13:22:40 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:YWY20z5vYMZF8/l++0rr7C09Foc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CDDt+7YyXZKwShN2o1FFAr1cbJrqSRZA9ZmEkiwZKt3HqBkLIEIsrq IqfwtSZMxaB8IsTJiiJ4EcWm1rIQ9v6Qc1BR+XoTQ= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Laurenz Albe schrieb am 19.09.2019 um 12:22: >> https://blog.jooq.org/2019/09/19/whats-faster-count-or-count1/ >> >> Is there a reason why count(*) seems to be faster? > > "count(*)" is just the SQL standard's way of saying what you'd > normally call "count()", that is, an aggregate without arguments. > > "count(1)" has to check if 1 IS NULL for each row, because NULL > values are not counted. "count(*)" doesn't have to do that. But 1 is a constant, why does it need to check it for each row?