Re: tableam vs. TOAST

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: tableam vs. TOAST
Date: 2019-05-21 18:10:53
Message-ID: CA+TgmoYTuT4sRtviMLOOO+79VnDCpCNyy9rK6UZFb7KEAVt21w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Updated and rebased patches attached.

On Fri, May 17, 2019 at 5:21 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> 0001 moves the needs_toast_table() calculation below the table AM
> layer. That allows a table AM to decide for itself whether it wants a
> TOAST table. The most obvious way in which a table AM might want to
> be different from what core expects is to decide that the answer is
> always "no," which it can do if it has some other method of storing
> large values or doesn't wish to support them. Another possibility is
> that it wants logic that is basically similar to the heap, but with a
> different size threshold because its tuple format is different. There
> are probably other possibilities.

This was committed as 1171d7d58545f26a402f76a05936d572bf29d53b per
discussion on another thread.

> 0002 breaks tuptoaster.c into three separate files. It just does code
> movement; no functional changes. The three pieces are detoast.c,
> which handles detoasting of toast values and inspection of the sizes
> of toasted datums; heaptoast.c, which keeps all the functions that are
> intrinsically heap-specific; and toast_internals.c, which is intended
> to have a very limited audience. A nice fringe benefit of this stuff
> is that a lot of other files that current have to include tuptoaster.h
> and thus htup_details.h no longer do.

Now 0001. No changes.

> 0003 creates a new file toast_helper.c which is intended to help table
> AMs implement insertion and deletion of toast table rows. Most of the
> AM-independent logic from the functions remaining in heaptoast.c is
> moved to this file. This leaves about ~600 of the original ~2400
> lines from tuptoaster.c as heap-specific logic, but a new heap AM
> actually wouldn't need all of that stuff, because some of the logic
> here is in support of stuff like record types, which use HeapTuple
> internally and will continue to do so even if those record types are
> stored in some other kind of table.

Now 0002. No changes.

> 0004 allows TOAST tables to be implemented using a table AM other than
> heap. In a certain sense this is the opposite of 0003. 0003 is
> intended to help people who are implementing a new kind of main table,
> whereas 0004 is intended to help people implementing a new kind of
> TOAST table. It teaches the code that inserts, deletes, and retrieves
> TOAST row to use slots, and it makes some efficiency improvements in
> the hopes of offsetting any performance loss from so doing. See
> commit message and/or patch for full details.

Now 0003. Some brain fade repaired.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
v2-0003-Allow-TOAST-tables-to-be-implemented-using-table-.patch application/octet-stream 36.6 KB
v2-0002-Create-an-API-for-inserting-and-deleting-rows-in-.patch application/octet-stream 30.0 KB
v2-0001-Split-tuptoaster.c-into-three-separate-files.patch application/octet-stream 163.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-05-21 18:12:56 Re: New EXPLAIN option: ALL
Previous Message Robert Haas 2019-05-21 18:03:50 Re: New EXPLAIN option: ALL