Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uVGEE-00G64D-Ll for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2025 21:03:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uVGEA-004XSK-Hv for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2025 21:03:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uVGEA-004XSA-9R for pgsql-bugs@lists.postgresql.org; Fri, 27 Jun 2025 21:03:18 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uVGE8-004KrG-32 for pgsql-bugs@lists.postgresql.org; Fri, 27 Jun 2025 21:03:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 55RL3Er72071612; Fri, 27 Jun 2025 17:03:14 -0400 From: Tom Lane To: victorq@extrahop.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18968: GiST Index Cost Estimation In-reply-to: <18968-eb7187b33887f562@postgresql.org> References: <18968-eb7187b33887f562@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 24 Jun 2025 23:00:41 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2071610.1751058194.1@sss.pgh.pa.us> Date: Fri, 27 Jun 2025 17:03:14 -0400 Message-ID: <2071611.1751058194@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When a text column has both a B-tree unique index and a GiST gist_trgm_ops > index, sometimes the planner estimates a slightly lower cost to use the GiST > index for an IN/ANY query with a constant list, but the actual cost to use > the GiST index is orders of magnitude higher than the B-tree index, e.g. 2 > min versus 6 ms in the example below. Is the GiST index cost estimate too > low for gist_trgm_ops? This seems similar to a relatively recent discussion > (2022) regarding GiN, GiST index cost (versus B-Tree) that led to a patch > https://www.postgresql.org/message-id/flat/3188617.44csPzL39Z%40aivenronan . Yeah, I complained at [1] that GIST and some of the other index types were not producing sane cost estimates compared to btree, but the thread trailed off after fixing only GIN. So that's still an open topic for investigation. If you can figure out how to improve matters, a patch would be welcome. regards, tom lane [1] https://www.postgresql.org/message-id/4153708.1662675130%40sss.pgh.pa.us