-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Currently, when executing queries that contain bytea
values on input or output, these are encoded from bytes and decoded to bytes on the level of the pgdb module and the pg.DB wrapper class.
This is needed because on the lowest level we use the PQexec()
method or the PQexecParams()
method without setting paramLengths
and paramFormats
. In both cases, Postgres only uses text format for input and output, so we need to encode and decode.
If we would always use PQexecParams()
and set paramLengths
and paramFormats
, we could avoid the encoding and decoding between bytes and bytea text format, by passing these values in binary format.
(Using binary could also speed up passing other parameters with types that have the same binary representation in Python and Postgres. But that could be brittle because it might depend on the Python and Postgres versions. However, bytes are always bytes, so it would be useful in the case of bytea. Also bytea values are usually big, so time and memory demand for encoding/decoding are more relevant for these.)
(copied from Trac ticket 53, created 2015-12-10)