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 1iAxAB-0007at-81 for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 14:12:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iAxAA-0003UF-6R for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 14:12:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAxA9-0003U6-Qr for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 14:12:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAxA4-0006Vw-0y for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 14:12:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8JEBqZX022759; Thu, 19 Sep 2019 10:11:52 -0400 From: Tom Lane To: Thomas Kellerer cc: pgsql-performance@lists.postgresql.org Subject: Re: Surprising benchmark count(1) vs. count(*) In-reply-to: <35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net> References: <35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net> Comments: In-reply-to Thomas Kellerer message dated "Thu, 19 Sep 2019 13:22:40 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22757.1568902312.1@sss.pgh.pa.us> Date: Thu, 19 Sep 2019 10:11:52 -0400 Message-ID: <22758.1568902312@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer writes: > Laurenz Albe schrieb am 19.09.2019 um 12:22: >> "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? [ shrug... ] There's no special optimization for that case. And I can't say that it seems attractive to add one. regards, tom lane