Re: PQgetlength vs. octet_length() - Mailing list pgsql-general

From Albe Laurenz
Subject Re: PQgetlength vs. octet_length()
Date
Msg-id D960CB61B694CF459DCFB4B0128514C203937ED1@exadv11.host.magwien.gv.at
Whole thread Raw
In response to PQgetlength vs. octet_length()  (Michael Clark <codingninja@gmail.com>)
List pgsql-general
Michael Clark wrote:
> That is what Pierre pointed out, and you are both right.  I
> am using the text mode.
>
> But it seems pretty crazy that a 140meg bit of data goes to
> 1.3 gigs.  Does that seem a bit excessive?
>
> I avoided the binary mode because that seemed to be rather
> confusing when having to deal with non-bytea data types.  The
> docs make it sound like binary mode should be avoided because
> what you get back for a datetime varies per platform.

That is true.

The best thing would be to retrieve only the bytea columns in
binary format and the rest as text.

The Bind message in the frontend/backend protocol allows to
specify for each individual result column whether it should
be text or binary
( http://www.postgresql.org/docs/current/static/protocol-message-formats.html )
but the C API only allows you to get *all* result columns in either
binary or text.

You could resort to either speaking line protocol with the backend,
(which is probably more than you are ready to do), or you could
create a separate query only for the bytea value.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Idle processes chewing up CPU?
Next
From: "Andrus Moor"
Date:
Subject: pg_restore returns always error if backup is greater than 2 GB