- // There are mainly the following two system tables. pg_largeobject_metadata records the permissions mainly. Only pg_largeobject is useful.
- CATALOG (FIG, 2995)
- {
- Oid lomowner;/* OID of the largeobject owner */
- # Ifdef CATALOG_VARLEN/* variable-length fields start here */
- Aclitem lomacl [1];/* Access permissions */
- # Endif
- } FormData_pg_largeobject_metadata;
- /*
- * Each "page" (tuple) of a large object can hold this much data
- *
- * We cocould set this as high as BLCKSZ less some overhead, but it seems
- * Better to make it a smaller value, so that not as much space is used
- * Up when a page-tuple is updated. Note that the value is deliberately
- * Chosen large enough to trigger the tuple toaster, so that we will
- * Attempt to compress page tuples in-line. (But they won't be moved off
- * Unless the user creates a toast-table for pg_largeobject ...)
- *
- * Also, it seems to be a smart move to make the page size be a power of 2,
- * Since clients will often be written to send data in power-of-2 blocks.
- * This avoids unnecessary tuple updates caused by partial-page writes.
- */
- # Define LOBLKSIZE (BLCKSZ/4)
- CATALOG (pg_largeobject, 2613) BKI_WITHOUT_OIDS
- {
- Oid loid;/* Identifier of large object */
- Int4 pageno;/* Page number (starting from 0 )*/
- /* Data has variable length, but we allow direct access; see inv_api.c */
- Bytea data;/* Data for page (may be zero-length )*/
- } FormData_pg_largeobject;
All the large objects are split into LOBLKSIZE values and placed into pg_largeobject. They are differentiated by loid. Each part of a large object is divided by pageno (the sequence number of the tuples is more reasonable ), in order,
Pageno is calculated based on the data offset/LOBLKSIZE to be written.
Pg's large object implementation is relatively simple and is not suitable for the use of large data volumes and will become a bottleneck of the system.