Data Type Picker

PostgreSQL

Categories

PostgresGUI

Binary

Use bytea; consider external storage for large files

byteavariable + 1-4 bytes overheadRecommended

Small binary data: hashes, encrypted tokens, thumbnails.


Range

up to 1 GB

Performance

Stored inline in the row (TOASTed if > 2 KB). Fine for small blobs.

Comparison

bytea vs large objects (lo): bytea is simpler and works with standard queries. Large objects support streaming but require special API. For files > 10 MB, consider external storage (S3).

SQL Example
CREATE TABLE files (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  sha256 bytea NOT NULL,
  thumbnail bytea
);
PostgreSQL Binary Type — bytea | PostgresGUI