forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1383e2a
committed
Improve FSM management for BRIN indexes.
BRIN indexes like to propagate additions of free space into the upper pagesof their free space maps as soon as the new space is known, even when it'sjust on one individual index page. Previously this required callingFreeSpaceMapVacuum, which is quite an expensive thing if the map is large.Use the FreeSpaceMapVacuumRange function recently added by commitc79f6dfto reduce the amount of work done for this purpose.Fix a couple of places that neglected to do the upper-page vacuuming at allafter recording new free space. If the policy is to be that BRIN should dothat, it should do it everywhere.Do RecordPageWithFreeSpace unconditionally in brin_page_cleanup, and doFreeSpaceMapVacuum unconditionally in brin_vacuum_scan. Because of theFSM's imprecise storage of free space, the old complications here seldombought anything, they just slowed things down. This approach alsoprovides a predictable path for FSM corruption to be repaired.Remove premature RecordPageWithFreeSpace call in brin_getinsertbufferwhere it's about to return an extended page to the caller. The callershould do that, instead, after it's inserted its new tuple. Fix theone caller that forgot to do so.Simplify logic in brin_doupdate's same-page-update case by postponingbrin_initialize_empty_new_buffer to after the critical section; I seelittle point in doing it before.Avoid repeat calls of RelationGetNumberOfBlocks in brin_vacuum_scan.Avoid duplicate BufferGetBlockNumber and BufferGetPage calls ina couple of places where we already had the right values.Move a BRIN_elog debug logging call out of a critical section; that'spretty unsafe and I don't think it buys us anything to not wait tillafter the critical section.Move the "*extended = false" step in brin_getinsertbuffer into theroutine's main loop. There's no actual bug there, since the loop can'titerate with *extended still true, but it doesn't seem very future-proofas coded; and it's certainly not documented as a loop invariant.This is all from follow-on investigation inspired by commitc79f6df.Discussion:https://postgr.es/m/5801.1522429460@sss.pgh.pa.us1 parent3de241d commit1383e2a
File tree
3 files changed
+103
-83
lines changed- src
- backend/access/brin
- include/access
3 files changed
+103
-83
lines changedLines changed: 18 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1121 | 1121 |
| |
1122 | 1122 |
| |
1123 | 1123 |
| |
1124 |
| - | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1125 | 1128 |
| |
1126 | 1129 |
| |
1127 | 1130 |
| |
| 1131 | + | |
| 1132 | + | |
1128 | 1133 |
| |
1129 | 1134 |
| |
1130 |
| - | |
1131 |
| - | |
1132 |
| - | |
| 1135 | + | |
| 1136 | + | |
1133 | 1137 |
| |
| 1138 | + | |
| 1139 | + | |
1134 | 1140 |
| |
1135 | 1141 |
| |
1136 | 1142 |
| |
| |||
1445 | 1451 |
| |
1446 | 1452 |
| |
1447 | 1453 |
| |
1448 |
| - | |
| 1454 | + | |
1449 | 1455 |
| |
1450 | 1456 |
| |
1451 | 1457 |
| |
1452 | 1458 |
| |
1453 | 1459 |
| |
1454 | 1460 |
| |
1455 |
| - | |
| 1461 | + | |
| 1462 | + | |
1456 | 1463 |
| |
1457 | 1464 |
| |
1458 | 1465 |
| |
| |||
1461 | 1468 |
| |
1462 | 1469 |
| |
1463 | 1470 |
| |
1464 |
| - | |
| 1471 | + | |
1465 | 1472 |
| |
1466 | 1473 |
| |
1467 | 1474 |
| |
1468 | 1475 |
| |
1469 | 1476 |
| |
1470 |
| - | |
1471 |
| - | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
1472 | 1480 |
| |
1473 |
| - | |
1474 |
| - | |
| 1481 | + | |
1475 | 1482 |
|
0 commit comments
Comments
(0)