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 1hdMVV-0007dQ-UL for pgsql-performance@arkaria.postgresql.org; Tue, 18 Jun 2019 22:23:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdMVU-0007sm-KY for pgsql-performance@arkaria.postgresql.org; Tue, 18 Jun 2019 22:23:12 +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 1hdMVU-0007sf-8M for pgsql-performance@lists.postgresql.org; Tue, 18 Jun 2019 22:23:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdMVN-00016j-5Y for pgsql-performance@lists.postgresql.org; Tue, 18 Jun 2019 22:23:11 +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 x5IMN01T025881; Tue, 18 Jun 2019 18:23:00 -0400 From: Tom Lane To: Andres Freund cc: AminPG Jaffer , pgsql-performance@lists.postgresql.org Subject: Re: Incorrect index used in few cases.. In-reply-to: <20190618221346.a5ql6n5s2zaheufb@alap3.anarazel.de> References: <802.1560864908@sss.pgh.pa.us> <23028.1560892075@sss.pgh.pa.us> <20190618221346.a5ql6n5s2zaheufb@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 18 Jun 2019 15:13:46 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25879.1560896580.1@sss.pgh.pa.us> Date: Tue, 18 Jun 2019 18:23:00 -0400 Message-ID: <25880.1560896580@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > Are those indexes used for other queries? Any chance they've been > recently created? > SELECT indexrelid::regclass, xmin, indcheckxmin, indisvalid, indisready, > indislive, txid_current(), txid_current_snapshot() > FROM pg_index WHERE indrelid = 'tc'::regclass; > might tell us. Oh, that's a good idea. > Amin, might be worth to see what the query plan is if you disable that > index. I assume it's too big to quickly drop (based on the ? Considering that the "right" query plan would have a cost estimate in the single digits or close to it, I have to suppose that the planner is rejecting that index as unusable, not making a cost-based decision not to use it. (Well, maybe if it's bloated by three orders of magnitude compared to the other indexes, it'd lose on cost. Doesn't seem likely though.) So I think we're looking for a hard "can't use the index" reason, and now we've eliminated datatype mismatch which'd be the most obvious such reason. But index-isnt-valid or index-isnt-ready might do the trick. regards, tom lane