forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1a8d5af
committed
Refactor the representation of indexable clauses in IndexPaths.
In place of three separate but interrelated lists (indexclauses,indexquals, and indexqualcols), an IndexPath now has one list"indexclauses" of IndexClause nodes. This holds basically the sameinformation as before, but in a more useful format: in particular, thereis now a clear connection between an indexclause (an original restrictionclause from WHERE or JOIN/ON) and the indexquals (directly usable indexconditions) derived from it.We also change the ground rules a bit by mandating that clause commutation,if needed, be done up-front so that what is stored in the indexquals listis always directly usable as an index condition. This gets rid of repeatedre-determination of which side of the clause is the indexkey during costingand plan generation, as well as repeated lookups of the commutatoroperator. To minimize the added up-front cost, the typical case ofcommuting a plain OpExpr is handled by a new special-purpose functioncommute_restrictinfo(). For RowCompareExprs, generating the new clauseproperly commuted to begin with is not really any more complex than before,it's just different --- and we can save doing that work twice, as thepretty-klugy original implementation did.Tracking the connection between original and derived clauses lets usalso track explicitly whether the derived clauses are an exact or lossytranslation of the original. This provides a cheap solution to gettingrid of unnecessary rechecks of boolean index clauses, which previouslyseemed like it'd be more expensive than it was worth.Another pleasant (IMO) side-effect is that EXPLAIN now always showsindex clauses with the indexkey on the left; this seems less confusing.This commit leaves expand_indexqual_conditions() and some relatedfunctions in a slightly messy state. I didn't bother to change themany more than minimally necessary to work with the new data structure,because all that code is going to be refactored out of existence ina follow-on patch.Discussion:https://postgr.es/m/22182.1549124950@sss.pgh.pa.us1 parent6401583 commit1a8d5af
File tree
22 files changed
+698
-622
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- util
- utils/adt
- include
- nodes
- optimizer
- utils
- test/regress/expected
22 files changed
+698
-622
lines changedLines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2192 | 2192 |
| |
2193 | 2193 |
| |
2194 | 2194 |
| |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
2195 | 2206 |
| |
2196 | 2207 |
| |
2197 | 2208 |
| |
| |||
2999 | 3010 |
| |
3000 | 3011 |
| |
3001 | 3012 |
| |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
3002 | 3024 |
| |
3003 | 3025 |
| |
3004 | 3026 |
| |
|
Lines changed: 15 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1744 | 1744 |
| |
1745 | 1745 |
| |
1746 | 1746 |
| |
1747 |
| - | |
1748 |
| - | |
1749 | 1747 |
| |
1750 | 1748 |
| |
1751 | 1749 |
| |
| |||
2447 | 2445 |
| |
2448 | 2446 |
| |
2449 | 2447 |
| |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
2450 | 2460 |
| |
2451 | 2461 |
| |
2452 | 2462 |
| |
| |||
4044 | 4054 |
| |
4045 | 4055 |
| |
4046 | 4056 |
| |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
4047 | 4060 |
| |
4048 | 4061 |
| |
4049 | 4062 |
| |
|
Lines changed: 19 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
148 |
| - | |
| 148 | + | |
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
| |||
517 | 517 |
| |
518 | 518 |
| |
519 | 519 |
| |
520 |
| - | |
521 |
| - | |
522 |
| - | |
| 520 | + | |
| 521 | + | |
523 | 522 |
| |
524 |
| - | |
| 523 | + | |
525 | 524 |
| |
526 | 525 |
| |
527 | 526 |
| |
528 | 527 |
| |
529 | 528 |
| |
530 | 529 |
| |
531 |
| - | |
| 530 | + | |
532 | 531 |
| |
533 | 532 |
| |
534 | 533 |
| |
| |||
753 | 752 |
| |
754 | 753 |
| |
755 | 754 |
| |
756 |
| - | |
757 |
| - | |
758 |
| - | |
759 |
| - | |
760 |
| - | |
761 |
| - | |
762 |
| - | |
763 |
| - | |
764 |
| - | |
765 |
| - | |
766 |
| - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
767 | 765 |
| |
768 | 766 |
| |
769 |
| - | |
| 767 | + | |
770 | 768 |
| |
771 | 769 |
| |
772 | 770 |
| |
| |||
777 | 775 |
| |
778 | 776 |
| |
779 | 777 |
| |
780 |
| - | |
781 |
| - | |
782 |
| - | |
783 |
| - | |
| 778 | + | |
| 779 | + | |
784 | 780 |
| |
785 | 781 |
| |
786 | 782 |
| |
| |||
4242 | 4238 |
| |
4243 | 4239 |
| |
4244 | 4240 |
| |
4245 |
| - | |
4246 |
| - | |
| 4241 | + | |
4247 | 4242 |
| |
4248 | 4243 |
| |
4249 | 4244 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2511 | 2511 |
| |
2512 | 2512 |
| |
2513 | 2513 |
| |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + |
0 commit comments
Comments
(0)