Scott Ribe <scott_ribe@elevated-dev.com> writes:
> On Apr 5, 2025, at 9:18 AM, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>> Also, compare the collations shown in the \l output for the database.
> And glibc versions...
Yeah, that. This smells very much like a collation-inconsistency
problem: random punctuation is exactly the sort of input that the
glibc authors tend to change collation behaviors for. I'm betting
that at some point the problematic database was physically copied
between two platforms with inconsistent collations. (The OP
mentioning use of two different Linux distros bolsters this
theory.) That made the index inconsistent with the new platform's
sorting behavior, and weird key lookup failures is exactly what
you get as a result of that.
Short answer: REINDEX whatever index the problematic query is
using, as well as any others on text columns, because they
likely have similar issues you haven't noticed yet.
regards, tom lane