Re: BUG #19031: pg_trgm infinite loop on certain cases
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>
Cc: washwithcare@gmail.com, pgsql-bugs@lists.postgresql.org,
Nikita Glukhov <glukhov.n.a@gmail.com>,
Alexander Korotkov <aekorotkov@gmail.com>
Date: 2025-08-27T14:32:26Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Put "excludeOnly" GIN scan keys at the end of the scankey array.
- d532069c391a 16.11 landed
- 4a593043eee9 14.20 landed
- 456c6a05d990 17.7 landed
- 3e0f5f00b34b 13.23 landed
- 3a7a3eaaf9fe 18.0 landed
- 34249b3b5847 15.15 landed
- 327b7324d071 19 (unreleased) landed
-
Do CHECK_FOR_INTERRUPTS inside, not before, scanGetItem.
- d17abaea8eda 17.7 landed
- b55068236c5e 19 (unreleased) landed
- b2d71c455f05 13.23 landed
- a9c1b9c1c606 15.15 landed
- a7da746c1177 14.20 landed
- 44c2e5b76c98 18.0 landed
- 25eadfd0fe7b 16.11 landed
Arseniy Mukhin <arseniy.mukhin.dev@gmail.com> writes: > Good point, thanks for the explanation. I forgot that there can be > many attributes. And I agree, the more determinism in the system, the > easier it is to work with it and the less room for bugs. OTOH it seems > from the performance POV we want to have the stricter keys to be the > first so we do less work and fail fast on the first keys. It looks > like these two rules (excludeOnly keys LAST and more restrictive keys > FIRST) are kind of in conflict with each other. I tried to do some > experiments and it's seems GIN quite sensitive to it, at least in this > artificial example: Yeah, it is. I recall seeing some comments to the effect that optimizing the order of scan keys would be a good thing, but if there is any code in there that tries to do so, I'm not seeing where. Seems like a fertile area for future research. > With applying patch both queries show the same time (second one). So > currently the user can tune the query by defining more restrictive > keys first. With the proposed fix it looks like users will have less > freedom here. I think most people would consider it a bug if they have to tune the order of the WHERE clauses manually. The original statement of the current bug was basically that: it worked in one order and not the other. regards, tom lane