Thread: RFC: multi TOAST-tables support

RFC: multi TOAST-tables support

From
Nikita Malakhov
Date:
Hi hackers!

Reference TOAST mechanics assumes that a relation has a single TOAST relation for all it's
TOASTable columns. While working on Pluggable TOAST [1] we've found that single TOAST 
relation for a relation is a bit of a problem, because different Toasters could have different 
TOAST table structure. Even for regular TOAST mechanism is is very strict limitation that limits 
size of storable data for the table by total size of TOASTed data, so even without Pluggable
TOAST this will be a great feature.

We've dealt with this a straightforward way - introduced the
Oid   *rd_toasterids; /* OIDs of attribute toasters, if any */
Oid   *rd_toastrelids; /* OIDs of toast relations corresponding to toasters, if any */
in the RelationData structure, but it seems to be not the best solution.

Another way is to store Toaster OID and TOAST relation ID in attoptions, which is less invasive,
and keep existing reltoastrelid field for default (reference) TOAST mechanism. But here we 
encounter new problem - when we assign another Toaster for the column we have to keep
somewhere all the old TOAST tables IDs, which looks like a problem for the attoptions.
Or maybe there is a better way to store TOAST relations ID for a column?

We'd like to get some feedback on how to implement this part.


Thanks in advance!

--
Regards,
Nikita Malakhov
Postgres Professional