Re: Index-only scan for btree_gist turns bpchar to char

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Japin Li <japinli(at)hotmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Index-only scan for btree_gist turns bpchar to char
Date: 2022-01-08 19:07:21
Message-ID: 1522234.1641668841@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> (Unfortunately for me) I found no anomalies related to gbt_text_same()
> with an index created with the previous implementation. I've added
> diagnostic logging that shows when gbt_text_same() returns 0 for keys
> that are the equal but have different padding. So I've observed that
> gbt_text_same() returns incorrect result, but all the btree_gist tests
> still pass. Moreover, unconditional "*result = 0;" in gbt_text_same()
> doesn't affect the tests at all.
> I've found that gbt_text_same() is called by gistKeyIsEQ() from
> backend/access/gist/gistutil.c, and made gistKeyIsEQ() return false any
> time. And even with such change all check-world tests still pass (except
> for isolation/predicate-gist that failed due to locking of pages split
> differently). So for now, I still don't know how to get incorrect query
> results due to incorrect gistKeyIsEQ() behavior/excessive page splitting.

Yeah, if that's the only use-case then it's pretty easy to see that
an overly strict equality test isn't going to hurt us much. At worst
it'll cause the index to be a little bit inefficiently stored due to
unnecessary node splits. Even then, that won't happen much in normal
use, since the discrepancy could only arise once in the lifespan of
an index node (when it first sees a new-style entry that could have
been considered equal to the old-style value).

So I think this solution will work, and I'll go ahead and push it.
Thanks for testing! (and for the original report ...)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jake North 2022-01-08 19:09:24 [feature request] ts_headline should have an option to highlight only full matches of <-> expressions
Previous Message Alexander Lakhin 2022-01-08 19:00:00 Re: Index-only scan for btree_gist turns bpchar to char