forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita808186
committed
Improve selectivity estimation for assorted match-style operators.
Quite a few matching operators such as JSONB's @> used "contsel" and"contjoinsel" as their selectivity estimators. That was a bad idea,because (a) contsel is only a stub, yielding a fixed default estimate,and (b) that default is 0.001, meaning we estimate these operators asfive times more selective than equality, which is surely pretty silly.There's a good model for improving this in ltree's ltreeparentsel():for any "var OP constant" query, we can try applying the operatorto all of the column's MCV and histogram values, taking the latteras being a random sample of the non-MCV values. That code isactually 100% generic, except for the question of exactly whatdefault selectivity ought to be plugged in when we don't have stats.Hence, migrate the guts of ltreeparentsel() into the core code, providewrappers "matchingsel" and "matchingjoinsel" with a more-appropriatedefault estimate, and use those for the non-geometric operators thatformerly used contsel (mostly JSONB containment operators and tsquerymatching).Also apply this code to some match-like operators in hstore, ltree, andpg_trgm, including the former users of ltreeparentsel as well as onesthat improperly used contsel. Since commit911e702 just created newversions of those extensions that we haven't released yet, we can sneakthis change into those new versions instead of having to create anadditional generation of update scripts.Patch by me, reviewed by Alexey BashtanovDiscussion:https://postgr.es/m/12237.1582833074@sss.pgh.pa.us1 parentd8653f4 commita808186
File tree
11 files changed
+332
-121
lines changed- contrib
- hstore
- ltree
- pg_trgm
- expected
- doc/src/sgml
- src
- backend/utils/adt
- include
- catalog
- utils
11 files changed
+332
-121
lines changedLines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + |
Lines changed: 81 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + |
Lines changed: 7 additions & 95 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
566 | 566 |
| |
567 | 567 |
| |
568 | 568 |
| |
569 |
| - | |
570 |
| - | |
571 | 569 |
| |
572 | 570 |
| |
| 571 | + | |
| 572 | + | |
| 573 | + | |
573 | 574 |
| |
574 | 575 |
| |
575 | 576 |
| |
| |||
578 | 579 |
| |
579 | 580 |
| |
580 | 581 |
| |
581 |
| - | |
582 |
| - | |
583 |
| - | |
584 | 582 |
| |
585 | 583 |
| |
586 |
| - | |
587 |
| - | |
588 |
| - | |
589 |
| - | |
590 |
| - | |
591 |
| - | |
592 |
| - | |
593 |
| - | |
594 |
| - | |
595 |
| - | |
596 |
| - | |
597 |
| - | |
598 |
| - | |
599 |
| - | |
600 |
| - | |
601 |
| - | |
602 |
| - | |
603 |
| - | |
604 |
| - | |
605 |
| - | |
606 |
| - | |
607 |
| - | |
608 |
| - | |
609 |
| - | |
610 |
| - | |
611 |
| - | |
612 |
| - | |
613 |
| - | |
614 |
| - | |
615 |
| - | |
616 |
| - | |
617 |
| - | |
618 |
| - | |
619 |
| - | |
620 |
| - | |
621 |
| - | |
622 |
| - | |
623 |
| - | |
624 |
| - | |
625 |
| - | |
626 |
| - | |
627 |
| - | |
628 |
| - | |
629 |
| - | |
630 |
| - | |
631 |
| - | |
632 |
| - | |
633 |
| - | |
634 |
| - | |
635 |
| - | |
636 |
| - | |
637 |
| - | |
638 |
| - | |
639 |
| - | |
640 |
| - | |
641 |
| - | |
642 |
| - | |
643 |
| - | |
644 |
| - | |
645 |
| - | |
646 |
| - | |
647 |
| - | |
648 |
| - | |
649 |
| - | |
650 |
| - | |
651 |
| - | |
652 |
| - | |
653 |
| - | |
654 |
| - | |
655 |
| - | |
656 |
| - | |
657 |
| - | |
658 |
| - | |
659 |
| - | |
660 |
| - | |
661 |
| - | |
662 |
| - | |
663 |
| - | |
664 |
| - | |
665 |
| - | |
666 |
| - | |
667 |
| - | |
668 |
| - | |
669 |
| - | |
670 |
| - | |
671 |
| - | |
672 |
| - | |
673 |
| - | |
674 |
| - | |
675 |
| - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
676 | 588 |
| |
677 | 589 |
| |
678 | 590 |
|
Lines changed: 9 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5170 | 5170 |
| |
5171 | 5171 |
| |
5172 | 5172 |
| |
5173 |
| - | |
5174 |
| - | |
5175 |
| - | |
5176 |
| - | |
5177 |
| - | |
5178 |
| - | |
5179 |
| - | |
5180 |
| - | |
5181 |
| - | |
5182 |
| - | |
| 5173 | + | |
| 5174 | + | |
| 5175 | + | |
| 5176 | + | |
| 5177 | + | |
| 5178 | + | |
| 5179 | + | |
| 5180 | + | |
| 5181 | + | |
5183 | 5182 |
| |
5184 | 5183 |
| |
5185 | 5184 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + |
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
285 | 297 |
| |
286 | 298 |
| |
287 | 299 |
| |
| |||
319 | 331 |
| |
320 | 332 |
| |
321 | 333 |
| |
| 334 | + | |
322 | 335 |
| |
323 | 336 |
| |
324 | 337 |
| |
|
0 commit comments
Comments
(0)