Hi, On 2018-12-11 13:59:55 -0500, Tom Lane wrote: > Andres Freund <and...@anarazel.de> writes: > > How's being unable to distinguish "never vacuumed" from "table is > > knowingly empty right now" not constrained by the representation? > > Well, OK, it is constrained, but even if it weren't I'd be afraid to > assume a table is totally empty, even if it was so the last time > ANALYZE looked at it. The plans you get from that are spectacularly > fragile.
I think some clamping would be acceptable, but three orders of magnitude off seems excessive. By clamping both the tuple density and the number of pages, we're essentially multiplying the error. But if this is your concern: Why are we believing that a previously vacuumed table is actually empty if it was previously one block long (relpages == 1), but not if it previously zero blocks long (relpages == 0). In the former case we're entering the /* quick exit if rel is clearly empty */ if (curpages == 0) { *tuples = 0; *allvisfrac = 0; break; } bit, but not in the latter case. Your fragility argument seems to hold about as much sway there. To me the whole logic around this largely seems to be cargo culting things forward. Greetings, Andres Freund