- Notifications
You must be signed in to change notification settings - Fork5.3k
Commit9e77323
committed
Allow indexscans on partial hash indexes with implied quals.
Normally, if a WHERE clause is implied by the predicate of a partialindex, we drop that clause from the set of quals used with the index,since it's redundant to test it if we're scanning that index.However, if it's a hash index (or any !amoptionalkey index), thiscould result in dropping all available quals for the index's firstkey, preventing us from generating an indexscan.It's fair to question the practical usefulness of this case. Sincehash only supports equality quals, the situation could only ariseif the index's predicate is "WHERE indexkey = constant", implyingthat the index contains only one hash value, which would make hasha really poor choice of index type. However, perhaps there areother !amoptionalkey index AMs out there with which such cases aremore plausible.To fix, just don't filter the candidate indexquals this way ifthe index is !amoptionalkey. That's a bit hokey because it mayresult in testing quals we didn't need to test, but to do itmore accurately we'd have to redundantly identify which candidatequals are actually usable with the index, something we don't knowat this early stage of planning. Doesn't seem worth the effort.Reported-by: Sergei Glukhov <s.glukhov@postgrespro.ru>Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: David Rowley <dgrowleyml@gmail.com>Discussion:https://postgr.es/m/e200bf38-6b45-446a-83fd-48617211feff@postgrespro.ruBackpatch-through: 141 parent9a26ff8 commit9e77323
File tree
5 files changed
+44
-0
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
5 files changed
+44
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3424 | 3424 | | |
3425 | 3425 | | |
3426 | 3426 | | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
3427 | 3437 | | |
3428 | 3438 | | |
3429 | 3439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
1274 | 1276 | | |
1275 | 1277 | | |
1276 | 1278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
85 | 104 | | |
86 | 105 | | |
87 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
377 | 380 | | |
378 | 381 | | |
379 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| |||
0 commit comments
Comments
(0)