forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5bba65d
committed
Fix a missed case in code for "moving average" estimate of reltuples.
It is possible for VACUUM to scan no pages at all, if the visibility mapshows that all pages are all-visible. In this situation VACUUM has no newinformation to report about the relation's tuple density, so it wasn'tchanging pg_class.reltuples ... but it updated pg_class.relpages anyway.That's wrong in general, since there is no evidence to justify changing thedensity ratio reltuples/relpages, but it's particularly bad if the previousstate was relpages=reltuples=0, which means "unknown tuple density".We just replaced "unknown" with "zero". ANALYZE would eventually recoverfrom this, but it could take a lot of repetitions of ANALYZE to do so ifthe relation size is much larger than the maximum number of pages ANALYZEwill scan, because of the moving-average behavior introduced by commitb4b6923.The only known situation where we could have relpages=reltuples=0 and yetthe visibility map asserts everything's visible is immediately followinga pg_upgrade. It might be advisable for pg_upgrade to try to preserve therelpages/reltuples statistics; but in any case this code is wrong on itsown terms, so fix it. Per report from Sergey Koposov.Back-patch to 8.4, where the visibility map was introduced, same as theprevious change.1 parentb83bb97 commit5bba65d
File tree
3 files changed
+37
-11
lines changed- src/backend
- commands
- utils/cache
3 files changed
+37
-11
lines changedLines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
493 | 493 |
| |
494 | 494 |
| |
495 | 495 |
| |
496 |
| - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
497 | 499 |
| |
498 | 500 |
| |
499 | 501 |
| |
|
Lines changed: 32 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
87 | 88 |
| |
88 | 89 |
| |
89 | 90 |
| |
| |||
154 | 155 |
| |
155 | 156 |
| |
156 | 157 |
| |
| 158 | + | |
| 159 | + | |
| 160 | + | |
157 | 161 |
| |
158 | 162 |
| |
159 | 163 |
| |
| |||
178 | 182 |
| |
179 | 183 |
| |
180 | 184 |
| |
| 185 | + | |
181 | 186 |
| |
182 | 187 |
| |
183 | 188 |
| |
| |||
207 | 212 |
| |
208 | 213 |
| |
209 | 214 |
| |
210 |
| - | |
211 |
| - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
212 | 226 |
| |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
213 | 239 |
| |
214 |
| - | |
| 240 | + | |
215 | 241 |
| |
216 |
| - | |
217 |
| - | |
218 |
| - | |
| 242 | + | |
219 | 243 |
| |
220 | 244 |
| |
221 | 245 |
| |
222 | 246 |
| |
223 |
| - | |
| 247 | + | |
224 | 248 |
| |
225 | 249 |
| |
226 | 250 |
| |
| |||
240 | 264 |
| |
241 | 265 |
| |
242 | 266 |
| |
243 |
| - | |
| 267 | + | |
244 | 268 |
| |
245 | 269 |
| |
246 | 270 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1415 | 1415 |
| |
1416 | 1416 |
| |
1417 | 1417 |
| |
1418 |
| - | |
1419 |
| - | |
| 1418 | + | |
| 1419 | + | |
1420 | 1420 |
| |
1421 | 1421 |
| |
1422 | 1422 |
| |
|
0 commit comments
Comments
(0)