forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit030cdaf
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 parent5795773 commit030cdaf
File tree
3 files changed
+37
-11
lines changed- src/backend
- commands
- utils/cache
3 files changed
+37
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
488 | 490 | | |
489 | 491 | | |
490 | 492 | | |
| |||
| 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 | | |
| |||
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
| 183 | + | |
179 | 184 | | |
180 | 185 | | |
181 | 186 | | |
| |||
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | | - | |
209 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
210 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
211 | 237 | | |
212 | | - | |
| 238 | + | |
213 | 239 | | |
214 | | - | |
215 | | - | |
216 | | - | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | 243 | | |
220 | 244 | | |
221 | | - | |
| 245 | + | |
222 | 246 | | |
223 | 247 | | |
224 | 248 | | |
| |||
238 | 262 | | |
239 | 263 | | |
240 | 264 | | |
241 | | - | |
| 265 | + | |
242 | 266 | | |
243 | 267 | | |
244 | 268 | | |
| |||
| 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)