forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit89e46da

Amit Kapila
Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber.
Using REPLICA IDENTITY FULL on the publisher can lead to a full table scanper tuple change on the subscription when REPLICA IDENTITY or PK index isnot available. This makes REPLICA IDENTITY FULL impractical to use apartfrom some small number of use cases.This patch allows using indexes other than PRIMARY KEY or REPLICAIDENTITY on the subscriber during apply of update/delete. The index thatcan be used must be a btree index, not a partial index, and it must haveat least one column reference (i.e. cannot consist of only expressions).We can uplift these restrictions in the future. There is no smartmechanism to pick the index. If there is more than one index thatsatisfies these requirements, we just pick the first one. We discussedusing some of the optimizer's low-level APIs for this but ruled it outas that can be a maintenance burden in the long run.This patch improves the performance in the vast majority of cases and theimprovement is proportional to the amount of data in the table. However,there could be some regression in a small number of cases where the indexeshave a lot of duplicate and dead rows. It was discussed that those aremostly impractical cases but we can provide a table or subscription leveloption to disable this feature if required.Author: Onder Kalaci, Amit KapilaReviewed-by: Peter Smith, Shi yu, Hou Zhijie, Vignesh C, Kuroda Hayato, Amit KapilaDiscussion:https://postgr.es/m/CACawEhVLqmAAyPXdHEPv1ssU2c=dqOniiGz7G73HfyS7+nGV4w@mail.gmail.com1 parent720de00 commit89e46da
File tree
6 files changed
+325
-69
lines changed- doc/src/sgml
- src
- backend
- executor
- replication/logical
- include/replication
- test/subscription
6 files changed
+325
-69
lines changedLines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
132 | 132 |
| |
133 | 133 |
| |
134 | 134 |
| |
135 |
| - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
136 | 143 |
| |
137 | 144 |
| |
138 | 145 |
| |
|
Lines changed: 79 additions & 33 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
| |||
37 | 38 |
| |
38 | 39 |
| |
39 | 40 |
| |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 |
| |
41 | 45 |
| |
42 | 46 |
| |
43 | 47 |
| |
44 |
| - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 |
| |
46 |
| - | |
47 |
| - | |
| 54 | + | |
| 55 | + | |
48 | 56 |
| |
49 |
| - | |
| 57 | + | |
50 | 58 |
| |
51 | 59 |
| |
52 | 60 |
| |
53 |
| - | |
| 61 | + | |
| 62 | + | |
54 | 63 |
| |
55 | 64 |
| |
56 | 65 |
| |
57 | 66 |
| |
58 |
| - | |
59 |
| - | |
60 |
| - | |
61 |
| - | |
62 | 67 |
| |
63 | 68 |
| |
64 | 69 |
| |
65 | 70 |
| |
66 | 71 |
| |
67 | 72 |
| |
68 |
| - | |
69 |
| - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 |
| |
71 | 77 |
| |
| 78 | + | |
72 | 79 |
| |
73 | 80 |
| |
74 |
| - | |
75 |
| - | |
76 |
| - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 |
| |
78 | 92 |
| |
79 | 93 |
| |
80 | 94 |
| |
81 | 95 |
| |
82 |
| - | |
| 96 | + | |
| 97 | + | |
83 | 98 |
| |
84 | 99 |
| |
85 | 100 |
| |
| |||
91 | 106 |
| |
92 | 107 |
| |
93 | 108 |
| |
94 |
| - | |
95 |
| - | |
| 109 | + | |
| 110 | + | |
96 | 111 |
| |
97 | 112 |
| |
98 |
| - | |
| 113 | + | |
99 | 114 |
| |
100 |
| - | |
| 115 | + | |
101 | 116 |
| |
102 | 117 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
108 | 122 |
| |
109 | 123 |
| |
110 |
| - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
111 | 128 |
| |
112 | 129 |
| |
113 | 130 |
| |
| |||
123 | 140 |
| |
124 | 141 |
| |
125 | 142 |
| |
| 143 | + | |
126 | 144 |
| |
127 | 145 |
| |
128 | 146 |
| |
129 | 147 |
| |
130 | 148 |
| |
| 149 | + | |
| 150 | + | |
131 | 151 |
| |
132 | 152 |
| |
133 | 153 |
| |
134 | 154 |
| |
135 |
| - | |
| 155 | + | |
| 156 | + | |
136 | 157 |
| |
137 |
| - | |
138 |
| - | |
139 |
| - | |
140 | 158 |
| |
141 | 159 |
| |
142 |
| - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
143 | 164 |
| |
144 | 165 |
| |
145 | 166 |
| |
146 | 167 |
| |
147 |
| - | |
| 168 | + | |
148 | 169 |
| |
149 | 170 |
| |
150 |
| - | |
| 171 | + | |
151 | 172 |
| |
152 |
| - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
153 | 195 |
| |
154 | 196 |
| |
155 | 197 |
| |
| |||
164 | 206 |
| |
165 | 207 |
| |
166 | 208 |
| |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
167 | 213 |
| |
168 | 214 |
| |
169 | 215 |
| |
|
0 commit comments
Comments
(0)