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 1ipw36-0003R1-Cc for pgsql-performance@arkaria.postgresql.org; Fri, 10 Jan 2020 15:18:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipw34-0002NG-UV for pgsql-performance@arkaria.postgresql.org; Fri, 10 Jan 2020 15:18:06 +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 1ipw34-0002N9-Hd for pgsql-performance@lists.postgresql.org; Fri, 10 Jan 2020 15:18:06 +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 1ipw32-0002ov-9u for pgsql-performance@lists.postgresql.org; Fri, 10 Jan 2020 15:18:05 +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 00AFI2ZO028697; Fri, 10 Jan 2020 10:18:02 -0500 From: Tom Lane To: Marco Colli cc: Justin Pryzby , pgsql-performance@lists.postgresql.org Subject: Re: Bad query plan when you add many OR conditions In-reply-to: References: <20200110030601.GH12066@telsasoft.com> <20200110133447.GI12066@telsasoft.com> Comments: In-reply-to Marco Colli message dated "Fri, 10 Jan 2020 15:53:22 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28695.1578669482.1@sss.pgh.pa.us> Date: Fri, 10 Jan 2020 10:18:02 -0500 Message-ID: <28696.1578669482@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Marco Colli writes: > As you can see it is a *index scan* and not an *index only* scan... I don't > understand why. The index includes all the fields used by the query... so > an index only scan should be possible. Huh? The query is "select * from ...", so it retrieves *all* columns of the table. regards, tom lane