When inserting a BYTEA string in PostgreSQL the documentation says that such a string will occupy 1 or 4 bytes plus byte string length.
The question that I can't seem to find the answer to is what determines whether 1 or 4 bytes are added and is this effect consistent or will it vary depending on some factor or other?
byteadata type. Toasting and tuple header overhead should be invisible at the libpq level. The data representation that you get back from e.g.PQexecis generally well-described by the libpq documentation (and pay attention to your setting ofbytea_output, of course). – Josh Kupershmidt Nov 21 '14 at 14:28