Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fDXsA-0006oC-6J for pgsql-general@arkaria.postgresql.org; Tue, 01 May 2018 16:11:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fDXs9-0003sk-1O for pgsql-general@arkaria.postgresql.org; Tue, 01 May 2018 16:11:21 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fDXs8-0003sa-Pl for pgsql-general@lists.postgresql.org; Tue, 01 May 2018 16:11:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fDXs2-00071J-6E for pgsql-general@postgresql.org; Tue, 01 May 2018 16:11:20 +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 w41GBCeq031535; Tue, 1 May 2018 12:11:12 -0400 From: Tom Lane To: Rob Sargent cc: "pgsql-general@postgresql.org" Subject: Re: Surprised by index choice for count(*) In-reply-to: <38fc1d14-1207-cbca-18e0-b2e6f269565b@gmail.com> References: <38fc1d14-1207-cbca-18e0-b2e6f269565b@gmail.com> Comments: In-reply-to Rob Sargent message dated "Tue, 01 May 2018 09:46:51 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <31533.1525191072.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 01 May 2018 12:11:12 -0400 Message-ID: <31534.1525191072@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Rob Sargent writes: > Should I be?  I would have thought the pk would have been chosen v. > function index? If I'm reading this correctly, the PK index contains uuids while the fpv index contains float4s, meaning the latter is probably half the size. So scanning it is a lot cheaper, at least according to the planner's cost model. regards, tom lane