IT lexicon › Database › BYTEA

BYTEA

Database På svenska → Updated: 2026-07-30

PostgreSQL type for binary data — images, encrypted fields, hash values. Default in-row storage with TOAST for large values. Distinct from LOBs (Large Objects) which are stored separately and accessed via OID streaming.

Representation in SQL: hex-escape ('\x48656c6c6f') or escape format. Limits: 1 GB per value (TOAST). Good for <1 MB binary data. For larger files: typically store on S3 + just URL in DB. Classic anti-pattern: blob 100 MB files in bytea → DB backup becomes 500 GB, replication lag, vacuum pain. MySQL equivalent: BLOB, MEDIUMBLOB (16 MB), LONGBLOB (4 GB). pg_dump over bytea is efficient but pg_basebackup is faster for large binary datasets.

← Back to the lexicon