forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5b93123
committed
Load relcache entries' partitioning data on-demand, not immediately.
Formerly the rd_partkey and rd_partdesc data structures were alwayspopulated immediately when a relcache entry was built or rebuilt.This patch changes things so that they are populated only when theyare first requested. (Hence, callers *must* now always useRelationGetPartitionKey or RelationGetPartitionDesc; just fetchingthe pointer directly is no longer acceptable.)This seems to have some performance benefits, but the main reason to doit is that it eliminates a recursive-reload failure that occurs if thepartkey or partdesc expressions contain any references to the relation'srowtype (as discovered by Amit Langote). In retrospect, since loadingthese data structures might result in execution of nearly-arbitrary codevia eval_const_expressions, it was a dumb idea to require that to happenduring relcache entry rebuild.Also, fix things so that old copies of a relcache partition descriptorwill be dropped when the cache entry's refcount goes to zero. In theprevious coding it was possible for such copies to survive for thelifetime of the session, as I'd complained of in a previous discussion.(This management technique still isn't perfect, but it's better thanbefore.) Improve the commentary explaining how that works and whyit's safe to hand out direct pointers to these relcache substructures.In passing, improve RelationBuildPartitionDesc by using the samememory-context-parent-swap approach used by RelationBuildPartitionKey,thereby making it less dependent on strong assumptions about whatpartition_bounds_copy does. Avoid doing get_rel_relkind in thecritical section, too.Patch by Amit Langote and Tom Lane; Robert Haas deserves some creditfor prior work in the area, too. Although this is a pre-existingproblem, no back-patch: the patch seems too invasive to be safe toback-patch, and the bug it fixes is a corner case that seemsrelatively unlikely to cause problems in the field.Discussion:https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.comDiscussion:https://postgr.es/m/CA+TgmoY3bRmGB6-DUnoVy5fJoreiBJ43rwMrQRCdPXuKt4Ykaw@mail.gmail.com1 parent8ce3aa9 commit5b93123
File tree
12 files changed
+186
-121
lines changed- src
- backend
- catalog
- commands
- executor
- partitioning
- utils/cache
- include
- partitioning
- utils
- test/regress
- expected
- sql
12 files changed
+186
-121
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
86 |
| - | |
87 | 86 |
| |
88 | 87 |
| |
89 | 88 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
812 | 812 |
| |
813 | 813 |
| |
814 | 814 |
| |
815 |
| - | |
| 815 | + | |
816 | 816 |
| |
817 | 817 |
| |
818 | 818 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 |
| - | |
34 | 33 |
| |
35 | 34 |
| |
36 | 35 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 |
| - | |
39 | 38 |
| |
40 | 39 |
| |
41 | 40 |
| |
| |||
775 | 774 |
| |
776 | 775 |
| |
777 | 776 |
| |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
778 | 782 |
| |
779 | 783 |
| |
780 | 784 |
| |
|
Lines changed: 77 additions & 35 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 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 | + | |
50 | 76 |
| |
51 | 77 |
| |
52 | 78 |
| |
53 | 79 |
| |
54 |
| - | |
55 |
| - | |
56 |
| - | |
57 |
| - | |
58 |
| - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
59 | 90 |
| |
60 |
| - | |
| 91 | + | |
61 | 92 |
| |
62 | 93 |
| |
63 | 94 |
| |
64 | 95 |
| |
65 | 96 |
| |
66 | 97 |
| |
67 | 98 |
| |
| 99 | + | |
68 | 100 |
| |
69 | 101 |
| |
70 | 102 |
| |
71 | 103 |
| |
| 104 | + | |
72 | 105 |
| |
73 | 106 |
| |
74 | 107 |
| |
| |||
81 | 114 |
| |
82 | 115 |
| |
83 | 116 |
| |
84 |
| - | |
| 117 | + | |
85 | 118 |
| |
86 | 119 |
| |
87 |
| - | |
| 120 | + | |
| 121 | + | |
88 | 122 |
| |
89 | 123 |
| |
90 | 124 |
| |
| |||
172 | 206 |
| |
173 | 207 |
| |
174 | 208 |
| |
| 209 | + | |
175 | 210 |
| |
176 | 211 |
| |
177 | 212 |
| |
178 | 213 |
| |
179 |
| - | |
180 |
| - | |
181 |
| - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
182 | 220 |
| |
183 | 221 |
| |
184 |
| - | |
185 |
| - | |
186 |
| - | |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 |
| - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
191 | 225 |
| |
192 |
| - | |
193 |
| - | |
194 |
| - | |
195 |
| - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
196 | 230 |
| |
197 | 231 |
| |
198 | 232 |
| |
199 |
| - | |
| 233 | + | |
200 | 234 |
| |
201 | 235 |
| |
202 | 236 |
| |
203 | 237 |
| |
204 |
| - | |
205 |
| - | |
206 |
| - | |
207 |
| - | |
208 |
| - | |
| 238 | + | |
209 | 239 |
| |
210 | 240 |
| |
211 | 241 |
| |
212 |
| - | |
213 | 242 |
| |
214 | 243 |
| |
215 | 244 |
| |
216 | 245 |
| |
217 | 246 |
| |
218 | 247 |
| |
219 |
| - | |
220 |
| - | |
221 |
| - | |
222 |
| - | |
| 248 | + | |
223 | 249 |
| |
224 | 250 |
| |
225 | 251 |
| |
226 | 252 |
| |
227 | 253 |
| |
228 | 254 |
| |
229 |
| - | |
230 |
| - | |
| 255 | + | |
231 | 256 |
| |
| 257 | + | |
232 | 258 |
| |
233 | 259 |
| |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
234 | 276 |
| |
235 | 277 |
| |
236 | 278 |
| |
|
Lines changed: 26 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| 40 | + | |
40 | 41 |
| |
41 | 42 |
| |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
42 | 65 |
| |
43 | 66 |
| |
44 | 67 |
| |
| |||
54 | 77 |
| |
55 | 78 |
| |
56 | 79 |
| |
57 |
| - | |
| 80 | + | |
58 | 81 |
| |
59 | 82 |
| |
60 | 83 |
| |
| |||
74 | 97 |
| |
75 | 98 |
| |
76 | 99 |
| |
77 |
| - | |
78 |
| - | |
79 |
| - | |
80 |
| - | |
81 | 100 |
| |
82 |
| - | |
| 101 | + | |
| 102 | + | |
83 | 103 |
| |
84 | 104 |
| |
85 | 105 |
| |
|
0 commit comments
Comments
(0)