From: | Nörder-Tuitje, Marcus <noerder-tuitje(at)technology(dot)de> |
---|---|
To: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Inefficient escape codes. |
Date: | 2005-10-20 07:15:17 |
Message-ID: | 16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
I guess, You should check, if a blob field and large object access is suitable for you - no escaping etc, just raw binary large objects.
AFAIK, PQExecParams is not the right solution for You. Refer the "Large object" section:
"28.3.5. Writing Data to a Large Object
The function
int lo_write(PGconn *conn, int fd, const char *buf, size_t len);writes len bytes from buf to large object descriptor fd. The fd argument must have been returned by a previous lo_open. The number of bytes actually written is returned. In the event of an error, the return value is negative."
regards,
Narcus
-----Ursprüngliche Nachricht-----
Von: pgsql-performance-owner(at)postgresql(dot)org
[mailto:pgsql-performance-owner(at)postgresql(dot)org]Im Auftrag von Michael
Fuhr
Gesendet: Dienstag, 18. Oktober 2005 22:47
An: Rodrigo Madera
Cc: pgsql-performance(at)postgresql(dot)org
Betreff: Re: [PERFORM] Inefficient escape codes.
[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]
On Tue, Oct 18, 2005 at 07:09:08PM +0000, Rodrigo Madera wrote:
> > What language and API are you using?
>
> I'm using libpqxx. A nice STL-style library for C++ (I am 101% C++).
I've only dabbled with libpqxx; I don't know if or how you can make
it send data in binary instead of text. See the documentation or
ask in a mailing list like libpqxx-general or pgsql-interfaces.
> > Binary transfer sends data in binary, not by automatically converting
> > to and from text.
>
> Uh, I'm sorry I didn't get that... If I send: insert into foo
> values('\\001\\002') will libpq send 0x01, 0x02 or "\\\\001\\\\002"??
If you do it that way libpq will send the string as text with escape
sequences; you can use a sniffer like tcpdump or ethereal to see this
for yourself. To send the data in binary you'd call PQexecParams()
with a query like "INSERT INTO foo VALUES ($1)". The $1 is a
placeholder; the other arguments to PQexecParams() provide the data
itself, the data type and length, and specify whether the data is in
text format or binary. See the libpq documentation for details.
--
Michael Fuhr
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
From | Date | Subject | |
---|---|---|---|
Next Message | Christian Paul B. Cosinas | 2005-10-20 08:43:34 | Deleting Records |
Previous Message | Tom Lane | 2005-10-20 04:58:51 | Re: Materializing a sequential scan |