Re: tableam vs. TOAST
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-05-21T18:10:53Z
Lists: pgsql-hackers
Attachments
- v2-0003-Allow-TOAST-tables-to-be-implemented-using-table-.patch (application/octet-stream) patch v2-0003
- v2-0002-Create-an-API-for-inserting-and-deleting-rows-in-.patch (application/octet-stream) patch v2-0002
- v2-0001-Split-tuptoaster.c-into-three-separate-files.patch (application/octet-stream) patch v2-0001
Updated and rebased patches attached. On Fri, May 17, 2019 at 5:21 PM Robert Haas <robertmhaas@gmail.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
Commits
-
tableam: New callback relation_fetch_toast_slice.
- ce242ae154dd 13.0 landed
-
tableam: Allow choice of toast AM.
- 83322e38da1a 13.0 landed
-
Move heap-specific detoasting logic into a separate function.
- e9fd0415e6e2 13.0 landed
-
Code cleanup for toast_fetch_datum and toast_fetch_datum_slice.
- d5406dea25b6 13.0 landed
-
Rename some toasting functions based on whether they are heap-specific.
- 2e8b6bfa90b2 13.0 landed
-
Create an API for inserting and deleting rows in TOAST tables.
- bd124996ef0d 13.0 landed
-
Split tuptoaster.c into three separate files.
- 8b94dab06617 13.0 landed
-
tableam: Move heap-specific logic from needs_toast_table below tableam.
- 1171d7d58545 12.0 cited