8
TOAST
Row version must fit into one page
some of the attributes can be compressed
or moved into a separate TOAST table
or both compressed and moved
TOAST table
pg_toast schema
supported by its own index
oversized attributes are divided into parts smaller than a page
accessed only when an oversized attribute is queried
native versioning
works transparently for the application
Any row version in PostgreSQL must fit entirely into one page. Oversized
row versions are stored using TOAST, The Oversized Attributes Storage
Technique. It implies several strategies. Firstly, the oversized attribute can
be compressed so that the row version fits into the page. If this fails, the
attribute can be moved into a separate service table. Both approaches can
be applied at the same time.
Any table can have a separate TOAST table (with a dedicated index)
created for it, if necessary. Such tables and indexes are located in a
separate pg_toast schema and therefore are usually hidden.
The row versions in the TOAST table must also fit into one page each, so
longer values are split into multiple chunks and transparently “glued”
together by PostgreSQL when the application demands.
TOAST tables are accessed only when an oversized attribute is being read
or changed. The tables have their own row versioning. Whenever a data
update in the main table does not modify the oversized value in the TOAST
table, the new row version in the main table will refer to the same old TOAST
value, saving disk space.