Re: Row estimates for empty tables
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Christophe Pettus <xof@thebuild.com>,
David Rowley <dgrowleyml@gmail.com>
Date: 2020-08-23T21:08:16Z
Lists: pgsql-hackers, pgsql-general
Attachments
- use-minus-one-for-unknown-reltuples-1.patch (text/x-diff) patch
Pavel Stehule <pavel.stehule@gmail.com> writes: > I am sending a patch that is years used in GoodData. I'm quite unexcited about that. I'd be the first to agree that the ten-pages estimate is a hack, but it's not an improvement to ask users to think of a better value ... especially not as a one-size-fits- all-relations GUC setting. I did have an idea that I think is better than my previous one: rather than lying about the value of relpages, let's represent the case where we don't know the tuple density by setting reltuples = -1 initially. This leads to a patch that's a good bit more invasive than the quick-hack solution, but I think it's a lot cleaner on the whole. A possible objection is that this changes the FDW API slightly, as GetForeignRelSize callbacks now need to deal with rel->tuples possibly being -1. We could avoid an API break if we made plancat.c clamp that value to zero; but then FDWs still couldn't tell the difference between the "empty" and "never analyzed" cases, and I think this is just as much of an issue for them as for the core code. I'll add this to the upcoming CF. regards, tom lane
Commits
-
Redefine pg_class.reltuples to be -1 before the first VACUUM or ANALYZE.
- 3d351d916b20 14.0 landed