Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jS4B4-00058n-1d for pgsql-performance@arkaria.postgresql.org; Fri, 24 Apr 2020 19:39:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jS4B2-0007mr-QX for pgsql-performance@arkaria.postgresql.org; Fri, 24 Apr 2020 19:39:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jS4B2-0007lY-J8 for pgsql-performance@lists.postgresql.org; Fri, 24 Apr 2020 19:39:56 +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 1jS4B0-0001cM-CQ for pgsql-performance@lists.postgresql.org; Fri, 24 Apr 2020 19:39:55 +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 03OJdqEq013458; Fri, 24 Apr 2020 15:39:52 -0400 From: Tom Lane To: Stephen Frost cc: Jeff Janes , Arcadio Ortega Reinoso , Pgsql Performance Subject: Re: PostgreSQL does not choose my indexes well In-reply-to: <20200424183323.GO13712@tamriel.snowman.net> References: <35dc90d6-e0c2-13b8-3184-e3db5d854a78@gmail.com> <20200424183323.GO13712@tamriel.snowman.net> Comments: In-reply-to Stephen Frost message dated "Fri, 24 Apr 2020 14:33:23 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13456.1587757192.1@sss.pgh.pa.us> Date: Fri, 24 Apr 2020 15:39:52 -0400 Message-ID: <13457.1587757192@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Stephen Frost writes: > Turns out to be because what was provided wasn't actually what was being > used- there's a domain in there and that seems to gum up the works and > make it so we don't consider the partial index as being something we can > use (see the discussion at the end of the other sub-thread). Some simple experiments here don't find that a domain-type column prevents use of the partial index. So it's still not entirely clear what's happening for the OP. I concur with Jeff's suggestion to try forcing use of the desired index, and see whether it happens at all and what the cost estimate is. I'm also wondering exactly which Postgres version this is. regards, tom lane