Re: tableam: abstracting relation sizing code

From: Michael Paquier <michael(at)paquier(dot)xyz>
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 02:08:27
Message-ID: 20190607020827.GB1736@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 06, 2019 at 04:40:53PM -0400, Robert Haas 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.
>
> 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.

Looks like a neat split.

"allvisfrac", "pages" and "tuples" had better be documented about
which result they represent.

+ * usable_bytes_per_page should contain the approximate number of bytes per
+ * page usable for tuple data, excluding the page header and any anticipated
+ * special space.
[...]
+table_block_estimate_rel_size(Relation rel, int32 *attr_widths,
+ BlockNumber *pages, double *tuples,
+ double *allvisfrac,
+ Size overhead_bytes_per_tuple,
+ Size usable_bytes_per_page)

Could you explain what's the use cases you have in mind for
usable_bytes_per_page? All AMs using smgr need to have a page header,
which implies that the usable number of bytes is (BLCKSZ - page
header) like heap for tuple data. In the AMs you got to work with, do
you store some extra data in the page which is not used for tuple
storage? I think that makes sense, just wondering about the use
case.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-06-07 02:29:49 Re: Custom table AMs need to include heapam.h because of BulkInsertState
Previous Message Amit Langote 2019-06-07 00:51:23 Re: behaviour change - default_tablesapce + partition table