forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit74388a1
committed
Avoid VACUUM reltuples distortion.
Add a heuristic that avoids distortion in the pg_class.reltuplesestimates used by VACUUM. Without the heuristic, successive manuallyrun VACUUM commands (run against a table that is never modified afterinitial bulk loading) will scan the same page in each VACUUM operation.Eventually pg_class.reltuples may reach the point where one single heappage is accidentally considered highly representative of the entiretable. This is likely to be completely wrong, since the last heap pagetypically has fewer tuples than average for the table.It's not obvious that this was a problem prior to commit44fa848, whichmade vacuumlazy.c consistently scan the last heap page (even when it isall-visible in the visibility map). It seems possible that there weremore subtle variants of the same problem that went unnoticed for quitesome time, though. Commit44fa848 simplified certain aspects of whenand how relation truncation was considered, but it did not introduce the"scan the last page" behavior. Essentially the same behavior wasintroduced much earlier, in commite842908. It was conditioned onwhether or not truncation looked promising towards the end of theinitial heap pass by VACUUM until recently, which was at least somewhatprotective. That doesn't seem like something that we should be relyingon, though.Author: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-WzkNKORurux459M64mR63Aw4Jq7MBRVcX=CvALqN3A88WA@mail.gmail.com1 parentd61a361 commit74388a1
1 file changed
+19
-0
lines changedLines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1238 | 1238 |
| |
1239 | 1239 |
| |
1240 | 1240 |
| |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
1241 | 1260 |
| |
1242 | 1261 |
| |
1243 | 1262 |
| |
|
0 commit comments
Comments
(0)