forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit86d911e
committed
Allow index AMs to cache data across aminsert calls within a SQL command.
It's always been possible for index AMs to cache data across successiveamgettuple calls within a single SQL command: the IndexScanDesc.opaquefield is meant for precisely that. However, no comparable facilityexists for amortizing setup work across successive aminsert calls.This patch adds such a feature and teaches GIN, GIST, and BRIN to use itto amortize catalog lookups they'd previously been doing on every call.(The other standard index AMs keep everything they need in the relcache,so there's little to improve there.)For GIN, the overall improvement in a statement that inserts many rowscan be as much as 10%, though it seems a bit less for the other two.In addition, this makes a really significant difference in runtimefor CLOBBER_CACHE_ALWAYS tests, since in those builds the repeatedcatalog lookups are vastly more expensive.The reason this has been hard up to now is that the aminsert function isnot passed any useful place to cache per-statement data. What I chose todo is to add suitable fields to struct IndexInfo and pass that to aminsert.That's not widening the index AM API very much because IndexInfo is alreadywithin the ken of ambuild; in fact, by passing the same info to aminsertas to ambuild, this is really removing an inconsistency in the AM API.Discussion:https://postgr.es/m/27568.1486508680@sss.pgh.pa.us1 parent7c5d8c1 commit86d911e
File tree
26 files changed
+117
-52
lines changed- contrib/bloom
- doc/src/sgml
- src
- backend
- access
- brin
- gin
- gist
- hash
- heap
- index
- nbtree
- spgist
- catalog
- commands
- executor
- include
- access
- nodes
26 files changed
+117
-52
lines changedLines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
190 | 190 |
| |
191 | 191 |
| |
192 | 192 |
| |
193 |
| - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
194 | 196 |
| |
195 | 197 |
| |
196 | 198 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
189 | 189 |
| |
190 | 190 |
| |
191 | 191 |
| |
192 |
| - | |
| 192 | + | |
| 193 | + | |
193 | 194 |
| |
194 | 195 |
| |
195 | 196 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
259 | 259 |
| |
260 | 260 |
| |
261 | 261 |
| |
262 |
| - | |
| 262 | + | |
| 263 | + | |
263 | 264 |
| |
264 | 265 |
| |
265 | 266 |
| |
| |||
287 | 288 |
| |
288 | 289 |
| |
289 | 290 |
| |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
290 | 299 |
| |
291 | 300 |
| |
292 | 301 |
| |
|
Lines changed: 15 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
| 134 | + | |
| 135 | + | |
135 | 136 |
| |
136 | 137 |
| |
137 |
| - | |
| 138 | + | |
138 | 139 |
| |
139 | 140 |
| |
140 | 141 |
| |
141 |
| - | |
| 142 | + | |
142 | 143 |
| |
143 | 144 |
| |
144 | 145 |
| |
| |||
163 | 164 |
| |
164 | 165 |
| |
165 | 166 |
| |
166 |
| - | |
| 167 | + | |
167 | 168 |
| |
168 | 169 |
| |
| 170 | + | |
169 | 171 |
| |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
170 | 178 |
| |
171 | 179 |
| |
172 | 180 |
| |
173 |
| - | |
| 181 | + | |
174 | 182 |
| |
175 | 183 |
| |
176 | 184 |
| |
| |||
261 | 269 |
| |
262 | 270 |
| |
263 | 271 |
| |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
| 272 | + | |
| 273 | + | |
268 | 274 |
| |
269 |
| - | |
270 | 275 |
| |
271 | 276 |
| |
272 | 277 |
| |
|
Lines changed: 18 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
482 | 482 |
| |
483 | 483 |
| |
484 | 484 |
| |
485 |
| - | |
| 485 | + | |
| 486 | + | |
486 | 487 |
| |
487 |
| - | |
| 488 | + | |
488 | 489 |
| |
489 | 490 |
| |
490 | 491 |
| |
491 | 492 |
| |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
492 | 503 |
| |
493 | 504 |
| |
494 | 505 |
| |
495 | 506 |
| |
496 | 507 |
| |
497 | 508 |
| |
498 |
| - | |
499 |
| - | |
500 | 509 |
| |
501 | 510 |
| |
502 | 511 |
| |
503 | 512 |
| |
504 | 513 |
| |
505 | 514 |
| |
506 |
| - | |
507 |
| - | |
| 515 | + | |
| 516 | + | |
508 | 517 |
| |
509 | 518 |
| |
510 | 519 |
| |
511 | 520 |
| |
512 |
| - | |
| 521 | + | |
513 | 522 |
| |
514 | 523 |
| |
515 | 524 |
| |
516 |
| - | |
517 |
| - | |
| 525 | + | |
| 526 | + | |
518 | 527 |
| |
519 | 528 |
| |
520 | 529 |
| |
|
Lines changed: 14 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
144 | 145 |
| |
145 | 146 |
| |
146 | 147 |
| |
147 |
| - | |
| 148 | + | |
| 149 | + | |
148 | 150 |
| |
| 151 | + | |
149 | 152 |
| |
150 |
| - | |
151 | 153 |
| |
152 | 154 |
| |
153 |
| - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
154 | 164 |
| |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 |
| - | |
159 |
| - | |
160 |
| - | |
161 |
| - | |
162 | 165 |
| |
163 | 166 |
| |
164 | 167 |
| |
| |||
169 | 172 |
| |
170 | 173 |
| |
171 | 174 |
| |
172 |
| - | |
| 175 | + | |
173 | 176 |
| |
174 | 177 |
| |
175 | 178 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
232 | 232 |
| |
233 | 233 |
| |
234 | 234 |
| |
235 |
| - | |
| 235 | + | |
| 236 | + | |
236 | 237 |
| |
237 | 238 |
| |
238 | 239 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1604 | 1604 |
| |
1605 | 1605 |
| |
1606 | 1606 |
| |
1607 |
| - | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
1608 | 1610 |
| |
1609 | 1611 |
| |
1610 | 1612 |
| |
| |||
1617 | 1619 |
| |
1618 | 1620 |
| |
1619 | 1621 |
| |
1620 |
| - | |
| 1622 | + | |
| 1623 | + | |
1621 | 1624 |
| |
1622 | 1625 |
| |
1623 | 1626 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
196 | 196 |
| |
197 | 197 |
| |
198 | 198 |
| |
199 |
| - | |
| 199 | + | |
| 200 | + | |
200 | 201 |
| |
201 | 202 |
| |
202 | 203 |
| |
| |||
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
211 |
| - | |
| 212 | + | |
212 | 213 |
| |
213 | 214 |
| |
214 | 215 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
276 | 276 |
| |
277 | 277 |
| |
278 | 278 |
| |
279 |
| - | |
| 279 | + | |
| 280 | + | |
280 | 281 |
| |
281 | 282 |
| |
282 | 283 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
206 | 206 |
| |
207 | 207 |
| |
208 | 208 |
| |
209 |
| - | |
| 209 | + | |
| 210 | + | |
210 | 211 |
| |
211 | 212 |
| |
212 | 213 |
| |
|
Lines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1687 | 1687 |
| |
1688 | 1688 |
| |
1689 | 1689 |
| |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
1690 | 1694 |
| |
1691 | 1695 |
| |
1692 | 1696 |
| |
| |||
3158 | 3162 |
| |
3159 | 3163 |
| |
3160 | 3164 |
| |
3161 |
| - | |
| 3165 | + | |
| 3166 | + | |
3162 | 3167 |
| |
3163 | 3168 |
| |
3164 | 3169 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
139 | 139 |
| |
140 | 140 |
| |
141 | 141 |
| |
142 |
| - | |
| 142 | + | |
| 143 | + | |
143 | 144 |
| |
144 | 145 |
| |
145 | 146 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
315 | 315 |
| |
316 | 316 |
| |
317 | 317 |
| |
| 318 | + | |
| 319 | + | |
318 | 320 |
| |
319 | 321 |
| |
320 | 322 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
168 |
| - | |
| 168 | + | |
| 169 | + | |
169 | 170 |
| |
170 | 171 |
| |
171 | 172 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
183 | 183 |
| |
184 | 184 |
| |
185 | 185 |
| |
| 186 | + | |
| 187 | + | |
186 | 188 |
| |
187 | 189 |
| |
188 | 190 |
| |
| |||
562 | 564 |
| |
563 | 565 |
| |
564 | 566 |
| |
| 567 | + | |
| 568 | + | |
565 | 569 |
| |
566 | 570 |
| |
567 | 571 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
391 | 391 |
| |
392 | 392 |
| |
393 | 393 |
| |
394 |
| - | |
| 394 | + | |
| 395 | + | |
395 | 396 |
| |
396 | 397 |
| |
397 | 398 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
75 |
| - | |
| 75 | + | |
| 76 | + | |
76 | 77 |
| |
77 | 78 |
| |
78 | 79 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
92 |
| - | |
| 92 | + | |
| 93 | + | |
93 | 94 |
| |
94 | 95 |
| |
95 | 96 |
| |
|
0 commit comments
Comments
(0)