Replicated large objects v6.4.0

PGD provides a replicated large object implementation that mirrors the PostgreSQL large object interface. Unlike standard PostgreSQL large objects, which aren't replicated by logical replication, PGD large objects are logically replicated across all nodes in the cluster. Object identifiers (OIDs) are generated using the galloc sequence to ensure uniqueness across all nodes.

Use replicated large objects when your application or driver relies on the PostgreSQL large object interface and you need that data replicated across all nodes. Replicated large objects are commonly used when migrating an existing application to PGD that already uses large objects, or when using a driver or ORM that manages binary data through the large object API.

For new applications, BYTEA is simpler and requires no special configuration. See Preparing your application for PGD for guidance on choosing the right approach.

Using replicated large objects

PGD offers two ways to work with replicated large objects: calling the bdr.lo_* functions directly, or enabling transparent redirection so existing applications work without code changes.

Calling bdr.lo_* functions

PGD exposes equivalents to all PostgreSQL large object server-side functions in the bdr schema, for example bdr.lo_create() instead of lo_create() and bdr.lo_open() instead of lo_open(). See Large object functions for the full function reference.

Redirecting PostgreSQL large object calls

Set bdr.override_large_objects = on to redirect calls to standard PostgreSQL lo_* functions to their bdr.lo_* equivalents automatically, so existing applications use replicated large objects without code changes.

Redirection applies to SQL-level calls. libpq-based clients and drivers also issue large object calls at the protocol level, bypassing SQL. To redirect those too, connect to the Connection Manager read-write port (default 6432) instead of connecting directly to Postgres.

How large objects are stored

Replicated large objects are stored in bdr.pgd_largeobject, with permissions stored in bdr.pgd_largeobject_metadata. These tables serve the same purpose as pg_catalog.largeobject and pg_catalog.largeobject_metadata, but their contents are replicated to all nodes.

Limitations

  • ALTER LARGE OBJECT isn't supported.
  • Large objects created before enabling this feature are stored in pg_catalog.largeobject and aren't accessible through the bdr.lo_* interface.
  • \lo_list in psql doesn't display PGD large objects because it reads pg_catalog.largeobject directly.