PG Bug reporting form <noreply@postgresql.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