forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcf2acaf
committed
Deprecate nbtree's BTP_HAS_GARBAGE flag.
Streamline handling of the various strategies that we have to avoid apage split in nbtinsert.c. When it looks like a leaf page is about tooverflow, we now perform deleting LP_DEAD items and deduplication in onecentral place. This greatly simplifies _bt_findinsertloc().This has an independently useful consequence: nbtree no longer relies onthe BTP_HAS_GARBAGE page level flag/hint for anything important. Westill set and unset the flag in the same way as before, but it's nolonger treated as a gating condition when considering if we should checkfor already-set LP_DEAD bits. This happens at the point where the pagelooks like it might have to be split anyway, so simply checking theLP_DEAD bits in passing is practically free. This avoids missingLP_DEAD bits just because the page-level hint is unset, which isprobably reasonably common (e.g. it happens when VACUUM unsets thepage-level flag without actually removing index tuples whose LP_DEAD-bitwas set recently, after the VACUUM operation began but before it reachedthe leaf page in question).Note that this isn't a big behavioral change compared to PostgreSQL 13.We were already checking for set LP_DEAD bits regardless of whether theBTP_HAS_GARBAGE page level flag was set before we considered doing adeduplication pass. This commit only goes slightly further by doing thesame check for all indexes, even indexes where deduplication won't beperformed.We don't completely remove the BTP_HAS_GARBAGE flag. We still rely onit as a gating condition with pg_upgrade'd indexes from before B-treeversion 4/PostgreSQL 12. That makes sense because we sometimes have tomake a choice among pages full of duplicates when inserting a tuple withpre version 4 indexes. It probably still pays to avoid accessing theline pointer array of a page there, since it won't yet be clear whetherwe'll insert on to the page in question at all, let alone split it as aresult.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Victor Yegorov <vyegorov@gmail.com>Discussion:https://postgr.es/m/CAH2-Wz%3DYpc1PDdk8OVJDChGJBjT06%3DA0Mbv9HyTLCsOknGcUFg%40mail.gmail.com1 parent7684b6f commitcf2acaf
File tree
6 files changed
+135
-130
lines changed- src
- backend/access/nbtree
- include/access
6 files changed
+135
-130
lines changedLines changed: 16 additions & 60 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
32 |
| - | |
33 |
| - | |
| 31 | + | |
34 | 32 |
| |
35 | 33 |
| |
36 | 34 |
| |
| |||
43 | 41 |
| |
44 | 42 |
| |
45 | 43 |
| |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 |
| - | |
53 |
| - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
54 | 50 |
| |
55 | 51 |
| |
56 |
| - | |
57 |
| - | |
| 52 | + | |
| 53 | + | |
58 | 54 |
| |
59 | 55 |
| |
60 | 56 |
| |
61 | 57 |
| |
62 | 58 |
| |
63 |
| - | |
| 59 | + | |
64 | 60 |
| |
65 |
| - | |
66 | 61 |
| |
67 |
| - | |
68 | 62 |
| |
69 | 63 |
| |
70 | 64 |
| |
71 | 65 |
| |
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 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 | 66 |
| |
112 | 67 |
| |
113 | 68 |
| |
114 | 69 |
| |
115 |
| - | |
116 | 70 |
| |
117 | 71 |
| |
118 | 72 |
| |
| |||
138 | 92 |
| |
139 | 93 |
| |
140 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
141 | 98 |
| |
142 | 99 |
| |
143 | 100 |
| |
| |||
259 | 216 |
| |
260 | 217 |
| |
261 | 218 |
| |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 |
| - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
266 | 222 |
| |
267 | 223 |
| |
268 | 224 |
| |
|
Lines changed: 95 additions & 47 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 |
| - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 |
| |
63 | 66 |
| |
64 | 67 |
| |
| |||
871 | 874 |
| |
872 | 875 |
| |
873 | 876 |
| |
874 |
| - | |
875 |
| - | |
876 |
| - | |
877 |
| - | |
878 |
| - | |
879 |
| - | |
880 |
| - | |
881 |
| - | |
882 |
| - | |
883 |
| - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
884 | 881 |
| |
885 | 882 |
| |
886 |
| - | |
887 |
| - | |
888 |
| - | |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 |
| - | |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 |
| - | |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
| 883 | + | |
| 884 | + | |
906 | 885 |
| |
907 | 886 |
| |
908 | 887 |
| |
| |||
942 | 921 |
| |
943 | 922 |
| |
944 | 923 |
| |
945 |
| - | |
946 |
| - | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
947 | 927 |
| |
948 | 928 |
| |
949 | 929 |
| |
| |||
993 | 973 |
| |
994 | 974 |
| |
995 | 975 |
| |
| 976 | + | |
| 977 | + | |
996 | 978 |
| |
997 |
| - | |
| 979 | + | |
| 980 | + | |
998 | 981 |
| |
999 | 982 |
| |
1000 | 983 |
| |
1001 | 984 |
| |
1002 | 985 |
| |
1003 |
| - | |
| 986 | + | |
1004 | 987 |
| |
1005 | 988 |
| |
1006 | 989 |
| |
| |||
2623 | 2606 |
| |
2624 | 2607 |
| |
2625 | 2608 |
| |
2626 |
| - | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
2627 | 2624 |
| |
2628 |
| - | |
2629 |
| - | |
2630 |
| - | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
2631 | 2637 |
| |
2632 | 2638 |
| |
2633 |
| - | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
2634 | 2643 |
| |
2635 | 2644 |
| |
2636 | 2645 |
| |
2637 | 2646 |
| |
2638 |
| - | |
2639 | 2647 |
| |
| 2648 | + | |
| 2649 | + | |
2640 | 2650 |
| |
2641 | 2651 |
| |
2642 | 2652 |
| |
2643 | 2653 |
| |
| 2654 | + | |
2644 | 2655 |
| |
2645 | 2656 |
| |
2646 | 2657 |
| |
2647 | 2658 |
| |
2648 | 2659 |
| |
2649 |
| - | |
2650 | 2660 |
| |
2651 |
| - | |
| 2661 | + | |
2652 | 2662 |
| |
2653 | 2663 |
| |
2654 | 2664 |
| |
| |||
2659 | 2669 |
| |
2660 | 2670 |
| |
2661 | 2671 |
| |
| 2672 | + | |
2662 | 2673 |
| |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
2663 | 2710 |
| |
2664 | 2711 |
| |
2665 |
| - | |
2666 |
| - | |
2667 |
| - | |
2668 |
| - | |
| 2712 | + | |
| 2713 | + | |
2669 | 2714 |
| |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
2670 | 2718 |
|
Lines changed: 16 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1187 | 1187 |
| |
1188 | 1188 |
| |
1189 | 1189 |
| |
1190 |
| - | |
1191 |
| - | |
| 1190 | + | |
| 1191 | + | |
1192 | 1192 |
| |
1193 | 1193 |
| |
1194 | 1194 |
| |
| |||
1215 | 1215 |
| |
1216 | 1216 |
| |
1217 | 1217 |
| |
1218 |
| - | |
1219 |
| - | |
1220 |
| - | |
1221 |
| - | |
1222 |
| - | |
1223 |
| - | |
| 1218 | + | |
1224 | 1219 |
| |
1225 |
| - | |
1226 |
| - | |
1227 |
| - | |
1228 |
| - | |
1229 |
| - | |
1230 |
| - | |
1231 |
| - | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1232 | 1224 |
| |
1233 | 1225 |
| |
1234 | 1226 |
| |
| |||
1310 | 1302 |
| |
1311 | 1303 |
| |
1312 | 1304 |
| |
1313 |
| - | |
1314 |
| - | |
| 1305 | + | |
1315 | 1306 |
| |
1316 | 1307 |
| |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1317 | 1316 |
| |
1318 | 1317 |
| |
1319 | 1318 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1877 | 1877 |
| |
1878 | 1878 |
| |
1879 | 1879 |
| |
1880 |
| - | |
| 1880 | + | |
| 1881 | + | |
1881 | 1882 |
| |
1882 | 1883 |
| |
1883 | 1884 |
| |
|
0 commit comments
Comments
(0)