- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit1dc5ebc
committed
Support "expanded" objects, particularly arrays, for better performance.
This patch introduces the ability for complex datatypes to have anin-memory representation that is different from their on-disk format.On-disk formats are typically optimized for minimal size, and in any casethey can't contain pointers, so they are often not well-suited forcomputation. Now a datatype can invent an "expanded" in-memory formatthat is better suited for its operations, and then pass that around amongthe C functions that operate on the datatype. There are also provisions(rudimentary as yet) to allow an expanded object to be modified in-placeunder suitable conditions, so that operations like assignment to an elementof an array need not involve copying the entire array.The initial application for this feature is arrays, but it is not hardto foresee using it for other container types like JSON, XML and hstore.I have hopes that it will be useful to PostGIS as well.In this initial implementation, a few heuristics have been hard-wiredinto plpgsql to improve performance for arrays that are stored inplpgsql variables. We would like to generalize those hacks so thatother datatypes can obtain similar improvements, but figuring out someappropriate APIs is left as a task for future work. (The heuristicsthemselves are probably not optimal yet, either, as they sometimesforce expansion of arrays that would be better left alone.)Preliminary performance testing shows impressive speed gains for plpgsqlfunctions that do element-by-element access or update of large arrays.There are other cases that get a little slower, as a result of added arrayformat conversions; but we can hope to improve anything that's annoyinglybad. In any case most applications should see a net win.Tom Lane, reviewed by Andres Freund1 parent8a2e1ed commit1dc5ebc
File tree
27 files changed
+2362
-526
lines changed- doc/src/sgml
- src
- backend
- access
- common
- heap
- executor
- utils
- adt
- mmgr
- include
- executor
- nodes
- utils
- pl/plpgsql/src
27 files changed
+2362
-526
lines changedLines changed: 40 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
503 | 503 |
| |
504 | 504 |
| |
505 | 505 |
| |
506 |
| - | |
507 |
| - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
508 | 509 |
| |
509 | 510 |
| |
510 | 511 |
| |
| |||
518 | 519 |
| |
519 | 520 |
| |
520 | 521 |
| |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
521 | 559 |
| |
522 | 560 |
| |
523 | 561 |
| |
|
Lines changed: 71 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
300 | 300 |
| |
301 | 301 |
| |
302 | 302 |
| |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
303 | 374 |
| |
304 | 375 |
| |
305 | 376 |
|
Lines changed: 37 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| 63 | + | |
63 | 64 |
| |
64 | 65 |
| |
65 | 66 |
| |
| |||
93 | 94 |
| |
94 | 95 |
| |
95 | 96 |
| |
| 97 | + | |
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
99 | 101 |
| |
100 | 102 |
| |
| 103 | + | |
101 | 104 |
| |
102 |
| - | |
| 105 | + | |
103 | 106 |
| |
104 | 107 |
| |
105 | 108 |
| |
| |||
108 | 111 |
| |
109 | 112 |
| |
110 | 113 |
| |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
111 | 124 |
| |
112 | 125 |
| |
113 |
| - | |
114 |
| - | |
115 |
| - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 |
| |
117 | 130 |
| |
118 | 131 |
| |
| |||
203 | 216 |
| |
204 | 217 |
| |
205 | 218 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
210 | 239 |
| |
211 | 240 |
| |
212 | 241 |
| |
|
Lines changed: 36 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| 40 | + | |
40 | 41 |
| |
41 | 42 |
| |
42 | 43 |
| |
| |||
130 | 131 |
| |
131 | 132 |
| |
132 | 133 |
| |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
133 | 147 |
| |
134 | 148 |
| |
135 | 149 |
| |
| |||
196 | 210 |
| |
197 | 211 |
| |
198 | 212 |
| |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
199 | 222 |
| |
200 | 223 |
| |
201 | 224 |
| |
| |||
263 | 286 |
| |
264 | 287 |
| |
265 | 288 |
| |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
266 | 294 |
| |
267 | 295 |
| |
268 | 296 |
| |
| |||
344 | 372 |
| |
345 | 373 |
| |
346 | 374 |
| |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
347 | 379 |
| |
348 | 380 |
| |
349 | 381 |
| |
| |||
400 | 432 |
| |
401 | 433 |
| |
402 | 434 |
| |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
403 | 439 |
| |
404 | 440 |
| |
405 | 441 |
| |
|
Lines changed: 4 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4248 | 4248 |
| |
4249 | 4249 |
| |
4250 | 4250 |
| |
4251 |
| - | |
4252 | 4251 |
| |
4253 | 4252 |
| |
4254 | 4253 |
| |
| |||
4265 | 4264 |
| |
4266 | 4265 |
| |
4267 | 4266 |
| |
4268 |
| - | |
| 4267 | + | |
| 4268 | + | |
4269 | 4269 |
| |
4270 | 4270 |
| |
4271 | 4271 |
| |
4272 | 4272 |
| |
4273 |
| - | |
4274 |
| - | |
4275 |
| - | |
4276 | 4273 |
| |
4277 | 4274 |
| |
4278 | 4275 |
| |
| |||
4302 | 4299 |
| |
4303 | 4300 |
| |
4304 | 4301 |
| |
4305 |
| - | |
| 4302 | + | |
4306 | 4303 |
| |
4307 | 4304 |
| |
4308 | 4305 |
| |
4309 | 4306 |
| |
4310 | 4307 |
| |
4311 | 4308 |
| |
4312 |
| - | |
4313 |
| - | |
| 4309 | + | |
4314 | 4310 |
| |
4315 | 4311 |
| |
4316 | 4312 |
| |
|
Lines changed: 47 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| 91 | + | |
91 | 92 |
| |
92 | 93 |
| |
93 | 94 |
| |
| |||
812 | 813 |
| |
813 | 814 |
| |
814 | 815 |
| |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
815 | 862 |
| |
816 | 863 |
| |
817 | 864 |
| |
|
0 commit comments
Comments
(0)