Re: Inefficient escape codes.

Поиск
Список
Период
Сортировка
От Nörder-Tuitje, Marcus
Тема Re: Inefficient escape codes.
Дата
Msg-id 16F953410A0F1346848DCB476A989CFE01D557@swtexchange2.technology.de
обсуждение исходный текст
Ответ на Inefficient escape codes.  (Rodrigo Madera <rodrigo.madera@gmail.com>)
Ответы Deleting Records  ("Christian Paul B. Cosinas" <cpc@cybees.com>)
Re: Inefficient escape codes.  (Rodrigo Madera <rodrigo.madera@gmail.com>)
Re: Inefficient escape codes.  ("Rodrigo Madera" <rodrigo.madera@gmail.com>)
Список pgsql-performance
I guess, You should check, if a blob field and large object access is suitable for you - no escaping etc, just raw
binarylarge 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
theevent 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



В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Materializing a sequential scan
Следующее
От: "Christian Paul B. Cosinas"
Дата:
Сообщение: Deleting Records