Commit e5adcb7
committed
Refactor nbtree insertion scankeys.
Use dedicated struct to represent nbtree insertion scan keys. Having a
dedicated struct makes the difference between search type scankeys and
insertion scankeys a lot clearer, and simplifies the signature of
several related functions. This is based on a suggestion by Andrey
Lepikhov.
Streamline how unique index insertions cache binary search progress.
Cache the state of in-progress binary searches within _bt_check_unique()
for later instead of having callers avoid repeating the binary search in
an ad-hoc manner. This makes it easy to add a new optimization:
_bt_check_unique() now falls out of its loop immediately in the common
case where it's already clear that there couldn't possibly be a
duplicate.
The new _bt_check_unique() scheme makes it a lot easier to manage cached
binary search effort afterwards, from within _bt_findinsertloc(). This
is needed for the upcoming patch to make nbtree tuples unique by
treating heap TID as a final tiebreaker column. Unique key binary
searches need to restore lower and upper bounds. They cannot simply
continue to use the >= lower bound as the offset to insert at, because
the heap TID tiebreaker column must be used in comparisons for the
restored binary search (unlike the original _bt_check_unique() binary
search, where scankey's heap TID column must be omitted).
Author: Peter Geoghegan, Heikki Linnakangas
Reviewed-By: Heikki Linnakangas, Andrey Lepikhov
Discussion: https://postgr.es/m/CAH2-WzmE6AhUdk9NdWBf4K3HjWXZBX3+umC7mH7+WDrKcRtsOw@mail.gmail.com1 parent 550b9d2 commit e5adcb7
File tree
9 files changed
+529
-387
lines changed- contrib/amcheck
- src
- backend
- access/nbtree
- utils/sort
- include/access
9 files changed
+529
-387
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
841 | | - | |
842 | 841 | | |
| 842 | + | |
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
| |||
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | | - | |
| 1033 | + | |
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| |||
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | | - | |
| 1085 | + | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
1114 | | - | |
| 1114 | + | |
1115 | 1115 | | |
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
| 1119 | + | |
1119 | 1120 | | |
1120 | 1121 | | |
1121 | 1122 | | |
| |||
1303 | 1304 | | |
1304 | 1305 | | |
1305 | 1306 | | |
1306 | | - | |
1307 | | - | |
| 1307 | + | |
| 1308 | + | |
1308 | 1309 | | |
1309 | 1310 | | |
1310 | 1311 | | |
| |||
1317 | 1318 | | |
1318 | 1319 | | |
1319 | 1320 | | |
1320 | | - | |
1321 | | - | |
| 1321 | + | |
| 1322 | + | |
1322 | 1323 | | |
1323 | 1324 | | |
1324 | 1325 | | |
| |||
1423 | 1424 | | |
1424 | 1425 | | |
1425 | 1426 | | |
1426 | | - | |
1427 | | - | |
| 1427 | + | |
1428 | 1428 | | |
1429 | 1429 | | |
1430 | 1430 | | |
| |||
1864 | 1864 | | |
1865 | 1865 | | |
1866 | 1866 | | |
1867 | | - | |
| 1867 | + | |
1868 | 1868 | | |
1869 | 1869 | | |
1870 | | - | |
1871 | 1870 | | |
1872 | 1871 | | |
1873 | | - | |
| 1872 | + | |
1874 | 1873 | | |
1875 | 1874 | | |
1876 | 1875 | | |
| |||
1883 | 1882 | | |
1884 | 1883 | | |
1885 | 1884 | | |
1886 | | - | |
| 1885 | + | |
1887 | 1886 | | |
1888 | 1887 | | |
1889 | | - | |
1890 | 1888 | | |
1891 | 1889 | | |
1892 | | - | |
| 1890 | + | |
1893 | 1891 | | |
1894 | 1892 | | |
1895 | 1893 | | |
| |||
1905 | 1903 | | |
1906 | 1904 | | |
1907 | 1905 | | |
1908 | | - | |
1909 | | - | |
1910 | | - | |
| 1906 | + | |
| 1907 | + | |
1911 | 1908 | | |
1912 | | - | |
1913 | 1909 | | |
1914 | 1910 | | |
1915 | | - | |
| 1911 | + | |
1916 | 1912 | | |
1917 | 1913 | | |
1918 | 1914 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
614 | 617 | | |
615 | 618 | | |
616 | 619 | | |
| |||
0 commit comments