Question Details

No question body available.

Tags

java postgresql spring-boot hibernate

Answers (1)

January 20, 2026 Score: 1 Rep: 257,900 Quality: Medium Completeness: 100%

Avoid Large Objects (what you call “Oid”) at all costs. Use bytea.

Some reasons:

  • Large Objects are a obsolescent leftover from the time before TOAST. Even the PostgreSQL documentation warns:

    PostgreSQL also supports a storage system called “TOAST”, which automatically stores values larger than a single database page into a secondary storage area per table. This makes the large object facility partially obsolete.

  • There is no referential integrity between large objects and the tables that reference them (via their oid). So you need to take special measures to keep your database consistent.

  • If you have many Large Objects, a database upgrade becomes slow and difficult. Before PostgreSQL v17, it could even happen that you cannot upgrade at all with too many Large Objects.

If it were not for the unfortunate choice of the JDBC driver and Hibernate to choose Large Objects by default to implement BLOB, they would hardly be used at all these days.