Can You Store Images in PostgreSQL? Tested

Yes: PostgreSQL stores images in a bytea column, as large objects, or as a path or URL to a file kept elsewhere.

On 1,000 incompressible 300 KB images, bytea used 4% extra space and large objects 33% extra.

Reads are fast; the cost is backups: a pg_dump of the bytea table took 28.7 seconds versus 0.09 seconds for a URL table.

Deleting a row does not delete its large object, so the space is never freed unless you unlink it.

Use bytea under about 1 MB and low traffic; use object storage plus a URL for big or popular images.

Read the full post

Read the full post