A rationale was given in the release notes of Postgres 9.0:
- Allow
bytea
values to be written in hex notation (Peter Eisentraut)The server parameter
bytea_output
controls whether hex or traditional format is used forbytea
output. Libpq'sPQescapeByteaConn()
function automatically uses the hex format when connected to PostgreSQL 9.0 or newer servers. However, pre-9.0 libpq versions will not correctly process hex format from newer servers.The new hex format will be directly compatible with more applications that use binary data, allowing them to store and retrieve it without extra conversion. It is also significantly faster to read and write than the traditional format.
You already seem to be aware of bytea_output
.