Re: BUG #18968: GiST Index Cost Estimation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: victorq(at)extrahop(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18968: GiST Index Cost Estimation
Date: 2025-06-27 21:03:14
Message-ID: 2071611.1751058194@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-06-27 21:06:08 Re: PGXS does not properly uninstall documentation
Previous Message Tom Lane 2025-06-27 18:35:50 Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references