Re: PQgetlength vs. octet_length()

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Michael Clark *EXTERN*" <codingninja(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>, "Greg Stark" <gsstark(at)mit(dot)edu>
Subject: Re: PQgetlength vs. octet_length()
Date: 2009-08-19 07:47:43
Message-ID: D960CB61B694CF459DCFB4B0128514C203937ED1@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrus Moor 2009-08-19 08:52:28 pg_restore returns always error if backup is greater than 2 GB
Previous Message Devrim GÜNDÜZ 2009-08-19 07:14:09 Re: question about /etc/init.d/postgresql in PGDG

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2009-08-19 07:58:13 Why ACL_EXECUTE is checked on FindConversion()?
Previous Message Albe Laurenz 2009-08-19 07:11:11 Re: PQgetlength vs. octet_length()