On Mon, Jun 10, 2019 at 3:46 PM Alvaro Herrera <alvhe...@2ndquadrant.com> wrote: > I agree that you're just moving the code, but this seems to have been > recently broken in 696d78469f37 -- it was correct before that (the > heuristic for never vacuumed rels was in optimizer/plancat.c). So in > reality the problem that Daniel pointed out is an open item for pg12.
I took a look at this but I don't see that Andres did anything in that commit other than move code. In the new code, heapam_estimate_rel_size() does this: + if (curpages < 10 && + relpages == 0 && + !rel->rd_rel->relhassubclass) + curpages = 10; + + /* report estimated # pages */ + *pages = curpages; + /* quick exit if rel is clearly empty */ + if (curpages == 0) + { + *tuples = 0; + *allvisfrac = 0; + return; + } And here's what the code in estimate_rel_size looked like before the commit you mention: if (curpages < 10 && rel->rd_rel->relpages == 0 && !rel->rd_rel->relhassubclass && rel->rd_rel->relkind != RELKIND_INDEX) curpages = 10; /* report estimated # pages */ *pages = curpages; /* quick exit if rel is clearly empty */ if (curpages == 0) { *tuples = 0; *allvisfrac = 0; break; } It's all the same, except that now that the test is in heap-specific code it no longer needs to test for RELKIND_INDEX. I may be missing something here, but I don't know what it is. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company