32. Large Objects
PostgreSQL™ has a large object facility, which provides stream-style access to user data that is stored in a special large-object structure. Streaming access is useful when working with data values that are too large to manipulate conveniently as a whole.
This chapter describes the implementation and the programming and query language interfaces to PostgreSQL™ large object data. We use the libpq C library for the examples in this chapter, but most programming interfaces native to PostgreSQL™ support equivalent functionality. Other interfaces might use the large object interface internally to provide generic support for large values. This is not described here.
All large objects are placed in a single system table called pg_largeobject. PostgreSQL™ also supports a storage system called «TOAST» that automatically stores values larger than a single database page into a secondary storage area per table. This makes the large object facility partially obsolete. One remaining advantage of the large object facility is that it allows values up to 2 GB in size, whereas TOASTed fields can be at most 1 GB. Also, large objects can be randomly modified using a read/write API that is more efficient than performing such operations using TOAST.