pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nörder-Tuitje, Marcus <noerder-tuitje@technology.de>
To: pgsql-performance@postgresql.org
Subject: Re: Inefficient escape codes.
Date: Thu, 20 Oct 2005 09:15:17 +0200
Message-ID: <16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de> (raw)

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@postgresql.org
[mailto:pgsql-performance-owner@postgresql.org]Im Auftrag von Michael
Fuhr
Gesendet: Dienstag, 18. Oktober 2005 22:47
An: Rodrigo Madera
Cc: pgsql-performance@postgresql.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?

               http://archives.postgresql.org





view thread (9+ messages)  latest in thread

Message-ID: <16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de>
Permalink:  ../16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de/
Also on:    postgresql.org/message-id/16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: noerder-tuitje@technology.de
  Subject: Re: Inefficient escape codes.
  In-Reply-To: <16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de>
  References: <16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox