forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdbc649f
committed
Speed up "rare & frequent" type GIN queries.
If you have a GIN query like "rare & frequent", we currently fetch all theitems that match either rare or frequent, call the consistent function foreach item, and let the consistent function filter out items that only matchone of the terms. However, if we can deduce that "rare" must be present forthe overall qual to be true, we can scan all the rare items, and for eachrare item, skip over to the next frequent item with the same or greater TID.That greatly speeds up "rare & frequent" type queries.To implement that, introduce the concept of a tri-state consistent function,where the 3rd value is MAYBE, indicating that we don't know if that term ispresent. Operator classes only provide a boolean consistent function, so wesimulate the tri-state consistent function by calling the boolean functionseveral times, with the MAYBE arguments set to all combinations of TRUE andFALSE. Testing all combinations is only feasible for a small number of MAYBEarguments, but it is envisioned that we'll provide a way for operatorclasses to provide a native tri-state consistent function, which can be muchmore efficient. But that is not included in this patch.We were already using that trick to for lossy pages, calling the consistentfunction with the lossy entry set to TRUE and FALSE. Now that we have thetri-state consistent function, use it for lossy pages too.Alexander Korotkov, with fair amount of refactoring by me.1 parente001030 commitdbc649f
File tree
5 files changed
+443
-99
lines changed- src
- backend/access/gin
- include/access
5 files changed
+443
-99
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
| 17 | + | |
18 | 18 |
| |
19 | 19 |
|
0 commit comments
Comments
(0)