forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4b754d6
committed
Avoid full scan of GIN indexes when possible
The strategy of GIN index scan is driven by opclass-specific extract_querymethod. This method that needed search mode is GIN_SEARCH_MODE_ALL. Thismode means that matching tuple may contain none of extracted entries. Simpleexample is '!term' tsquery, which doesn't need any term to exist in matchingtsvector.In order to handle such scan key GIN calculates virtual entry, which containsall TIDs of all entries of attribute. In fact this is full scan of indexattribute. And typically this is very slow, but allows to handle some queriescorrectly in GIN. However, current algorithm calculate such virtual entry foreach GIN_SEARCH_MODE_ALL scan key even if they are multiple for the sameattribute. This is clearly not optimal.This commit improves the situation by introduction of "exclude only" scan keys.Such scan keys are not capable to return set of matching TIDs. Instead, theyare capable only to filter TIDs produced by normal scan keys. Therefore,each attribute should contain at least one normal scan key, while rest of themmay be "exclude only" if search mode is GIN_SEARCH_MODE_ALL.The same optimization might be applied to the whole scan, not per-attribute.But that leads to NULL values elimination problem. There is trade-off betweenmultiple possible ways to do this. We probably want to do this later usingsome cost-based decision algorithm.Discussion:https://postgr.es/m/CAOBaU_YGP5-BEt5Cc0%3DzMve92vocPzD%2BXiZgiZs1kjY0cj%3DXBg%40mail.gmail.comAuthor: Nikita Glukhov, Alexander Korotkov, Tom Lane, Julien RouhaudReviewed-by: Julien Rouhaud, Tomas Vondra, Tom Lane1 parent41c6f9d commit4b754d6
File tree
10 files changed
+579
-77
lines changed- contrib/pg_trgm
- expected
- sql
- src
- backend
- access/gin
- utils/adt
- include/access
- test/regress
- expected
- sql
10 files changed
+579
-77
lines changedLines changed: 101 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3498 | 3498 |
| |
3499 | 3499 |
| |
3500 | 3500 |
| |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
3501 | 3602 |
| |
3502 | 3603 |
| |
3503 | 3604 |
| |
|
Lines changed: 27 additions & 0 deletions
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 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
58 | 85 |
| |
59 | 86 |
| |
60 | 87 |
| |
|
Lines changed: 64 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
528 | 528 |
| |
529 | 529 |
| |
530 | 530 |
| |
| 531 | + | |
| 532 | + | |
531 | 533 |
| |
532 |
| - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
533 | 545 |
| |
534 | 546 |
| |
535 | 547 |
| |
| |||
1008 | 1020 |
| |
1009 | 1021 |
| |
1010 | 1022 |
| |
1011 |
| - | |
| 1023 | + | |
1012 | 1024 |
| |
1013 | 1025 |
| |
1014 | 1026 |
| |
1015 | 1027 |
| |
1016 | 1028 |
| |
1017 | 1029 |
| |
1018 |
| - | |
1019 |
| - | |
1020 |
| - | |
1021 |
| - | |
1022 |
| - | |
1023 |
| - | |
1024 |
| - | |
1025 |
| - | |
1026 |
| - | |
| 1030 | + | |
1027 | 1031 |
| |
1028 |
| - | |
1029 |
| - | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1030 | 1041 |
| |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1031 | 1053 |
| |
1032 | 1054 |
| |
1033 |
| - | |
| 1055 | + | |
1034 | 1056 |
| |
1035 | 1057 |
| |
1036 | 1058 |
| |
1037 | 1059 |
| |
1038 |
| - | |
1039 |
| - | |
1040 |
| - | |
1041 |
| - | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1042 | 1069 |
| |
1043 | 1070 |
| |
1044 | 1071 |
| |
| |||
1266 | 1293 |
| |
1267 | 1294 |
| |
1268 | 1295 |
| |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1269 | 1310 |
| |
1270 | 1311 |
| |
1271 | 1312 |
| |
| |||
1736 | 1777 |
| |
1737 | 1778 |
| |
1738 | 1779 |
| |
1739 |
| - | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
1740 | 1784 |
| |
1741 | 1785 |
| |
1742 | 1786 |
| |
1743 |
| - | |
| 1787 | + | |
1744 | 1788 |
| |
1745 | 1789 |
| |
1746 | 1790 |
| |
|
0 commit comments
Comments
(0)