forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7d07128
committed
Fix an O(N^2) problem in foreign key references.
Commit45ba424 improved foreign key lookups during bulk updateswhen the FK value does not change. When restoring a schema dumpfrom a database with many (say 100,000) foreign keys, this cachewould grow very big and every ALTER TABLE command was causing anInvalidateConstraintCacheCallBack(), which uses a sequential hashtable scan. This could cause a severe performance regression inrestoring a schema dump (including during pg_upgrade).The patch uses a heuristic method of detecting when the hash tableshould be destroyed and recreated.InvalidateConstraintCacheCallBack() adds the current size of thehash table to a counter. When that sum reaches 1,000,000, the hashtable is flushed. This fixes the regression without noticeableharm to the bulk update use case.Jan WieckBackpatch to 9.3 where the performance regression was introduced.1 parent907f3a9 commit7d07128
1 file changed
+35
-3
lines changedLines changed: 35 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
182 | 182 |
| |
183 | 183 |
| |
184 | 184 |
| |
| 185 | + | |
185 | 186 |
| |
186 | 187 |
| |
187 | 188 |
| |
| |||
214 | 215 |
| |
215 | 216 |
| |
216 | 217 |
| |
| 218 | + | |
217 | 219 |
| |
218 | 220 |
| |
219 | 221 |
| |
| |||
2932 | 2934 |
| |
2933 | 2935 |
| |
2934 | 2936 |
| |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
2935 | 2951 |
| |
2936 | 2952 |
| |
2937 | 2953 |
| |
| |||
3327 | 3343 |
| |
3328 | 3344 |
| |
3329 | 3345 |
| |
3330 |
| - | |
| 3346 | + | |
3331 | 3347 |
| |
3332 |
| - | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
3333 | 3351 |
| |
3334 | 3352 |
| |
3335 | 3353 |
| |
3336 |
| - | |
| 3354 | + | |
3337 | 3355 |
| |
3338 | 3356 |
| |
3339 | 3357 |
| |
| |||
3344 | 3362 |
| |
3345 | 3363 |
| |
3346 | 3364 |
| |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
3347 | 3379 |
| |
3348 | 3380 |
| |
3349 | 3381 |
| |
|
0 commit comments
Comments
(0)