> On 6 Jun 2019, at 22:40, Robert Haas <robertmhaas@gmail.com> wrote:
> It looks to me as though any table AM that uses the relation forks
> supported by PostgreSQL in a more or less normal manner is likely to
> require an implementation of the relation_size callback that is
> identical to the one for heap, and an implementation of the
> estimate_rel_size method that is extremely similar to the one for
> heap. The latter is especially troubling as the amount of code
> duplication is non-trivial, and it's full of special hacks.
Makes sense. Regarding one of the hacks:
+ * HACK: if the relation has never yet been vacuumed, use a minimum size
+ * estimate of 10 pages. The idea here is to avoid assuming a
+ * newly-created table is really small, even if it currently is, because
+ * that may not be true once some data gets loaded into it.
When this is a generic function for AM’s, would it make sense to make the
minimum estimate a passed in value rather than hardcoded at 10? I don’t have a
case in mind, but I also don’t think that assumptions made for heap necessarily
makes sense for all AM’s. Just thinking out loud.
> Here is a patch that tries to improve the situation. I don't know
> whether there is some better approach; this seemed like the obvious
> thing to do.
A small nitpick on the patch:
+ * estimate_rel_size callback, because it has a few additional paramters.
s/paramters/parameters/
cheers ./daniel