Re: tableam: abstracting relation sizing code

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: tableam: abstracting relation sizing code
Date: 2019-06-07 08:11:45
Message-ID: 169A2D7A-E8DA-4EF7-A9DE-EB7A482783B7@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 6 Jun 2019, at 22:40, Robert Haas <robertmhaas(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2019-06-07 09:07:34 Missing generated column in ALTER TABLE ADD COLUMN doc
Previous Message Kyotaro Horiguchi 2019-06-07 08:06:09 Wording variations in descriptions of gucs.