Question

In PostgreSQL, how can I tell whether a text column is stored inline or stored in a "background table"?

Documentation for text column types says that

Very long values are also stored in background tables so that they do not interfere with rapid access to shorter column values.

Is there a fixed length at which a value is determined to be "very long"? If not, are there other ways of telling how my columns are laid out on disk? I have a table with several columns that are text (or varchar(n)) and want to understand how they are stored under the hood. Is there more documentation on these "background tables" somewhere?

Was it helpful?

Solution 2

If your table is called t1, then enter \d+ t1 at your psql prompt, it will show a column storage mode.

OTHER TIPS

Any varlena data type (all types with variable length or types longer than 4 bytes (32 bits) or 8 bytes (64 bits)) can be TOASTed - TOAST is a process that tries to reduce long rows (records) to 8KB page size.

Row size is checked before physically storing to the relation. When the size exceeds 2KB, most larger fields are selected, compressed, sliced to 2KB chunks and moved to a secondary table file with the suffix _toast. A pointer to the toast file replaces the data in the main storage. This process is repeated while the row is bigger than 2KB.

Follow the links provided by a_horse_with_no_name and IMSoP for more detailed documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top