![]() Alternatively, a TOAST pointer datum can contain a pointer to out-of-line data that appears elsewhere in memory. Further details appear in Section 73.2.1. These on-disk pointer datums are created by the TOAST management code (in access/common/toast_internals.c) when a tuple to be stored on disk is too large to be stored as-is. The oldest and most common type is a pointer to out-of-line data stored in a TOAST table that is separate from, but associated with, the table containing the TOAST pointer datum itself. The default for columns with no explicit setting is to consult the default_toast_compression parameter at the time data is inserted.Īs mentioned, there are multiple types of TOAST pointer datums. The compression technique used for either in-line or out-of-line compressed data can be selected for each column by setting the COMPRESSION column option in CREATE TABLE or ALTER TABLE. Note that compression is also possible for out-of-line data but the varlena header does not tell whether it has occurred - the content of the TOAST pointer tells that, instead. In this case the remaining bits of the four-byte length word give the total size of the compressed datum, not the original data. Lastly, when the highest-order or lowest-order bit is clear but the adjacent bit is set, the content of the datum has been compressed and must be decompressed before use. The type and size of such a TOAST pointer are determined by a code stored in the second byte of the datum. As a special case, if the remaining bits of a single-byte header are all zero (which would be impossible for a self-inclusive length), the value is a pointer to out-of-line data, with several possible alternatives as described below. Values with single-byte headers aren't aligned on any particular boundary, whereas values with four-byte headers are aligned on at least a four-byte boundary this omission of alignment padding provides additional space savings that is significant compared to short values. This alternative supports space-efficient storage of values shorter than 127 bytes, while still allowing the data type to grow to 1 GB at need. ![]() When the highest-order or lowest-order bit is set, the value has only a single-byte header instead of the normal four-byte header, and the remaining bits of that byte give the total datum size (including length byte) in bytes. When both bits are zero, the value is an ordinary un- TOASTed value of the data type, and the remaining bits of the length word give the total datum size (including length word) in bytes. TOAST usurps two bits of the varlena length word (the high-order bits on big-endian machines, the low-order bits on little-endian machines), thereby limiting the logical size of any value of a TOAST-able data type to 1 GB (2 30 - 1 bytes). ![]() (This is normally done by invoking PG_DETOAST_DATUM before doing anything with an input value, but in some cases more efficient approaches are possible. Therefore, the C-level functions supporting a TOAST-able data type must be careful about how they handle potentially TOASTed input values: an input might not actually consist of a four-byte length word and contents until after it's been detoasted. The special representations collectively called TOASTed values work by modifying or reinterpreting this initial length word. TOAST does not constrain the rest of the data type's representation. To support TOAST, a data type must have a variable-length ( varlena) representation, in which, ordinarily, the first four-byte word of any stored value contains the total length of the value in bytes (including itself). Only certain data types support TOAST - there is no need to impose the overhead on data types that cannot produce large field values. The TOAST infrastructure is also used to improve handling of large data values in-memory. The technique is affectionately known as TOAST (or “ the best thing since sliced bread”). This happens transparently to the user, with only small impact on most of the backend code. To overcome this limitation, large field values are compressed and/or broken up into multiple physical rows. Therefore, it is not possible to store very large field values directly. PostgreSQL uses a fixed page size (commonly 8 kB), and does not allow tuples to span multiple pages. This section provides an overview of TOAST (The Oversized-Attribute Storage Technique). Out-of-Line, On-Disk TOAST Storage 73.2.2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |