Large Objects (LOBs)

In PostgreSQL, data values are stored in tuples and individual tuples cannot span data pages. Since the size of a data page is 8192 bytes, the upper limit on the size of a data value is relatively low. To support the storage of larger atomic values, PostgreSQL provides a large object (LOB) facility.

Note

Originally, PostgreSQL supported three implementations of large objects: as files external to PostgreSQL, as external files managed by PostgreSQL, and as data stored within the database. This caused considerable confusion among users. As a result, PostgreSQL now supports only the latter option (large objects as data stored within the database). Although this implementation is slightly slower to access, it provides stricter data integrity.

Unlike the SQL99 standard, PostgreSQL does not make any distinction between character or binary large objects. Also, in PostgreSQL there is no specific type for large objects. A column that will contain a LOB must be defined as type "oid". The implementation breaks large objects into "chunks" and stores the chunks in tuples in the database. A B-tree index guarantees fast searches for the correct chunk number when doing random access reads and writes.

Note

For historical reasons, this storage scheme is sometimes referred to as Inversion large objects.

PostgreSQL provides built-in functions to access large objects (see Chapter 3).