X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95748DA027 for ; Wed, 19 Oct 2005 04:19:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59843-06 for ; Wed, 19 Oct 2005 07:19:03 +0000 (GMT) Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.197]) by svr1.postgresql.org (Postfix) with ESMTP id AFA64D9FFA for ; Wed, 19 Oct 2005 04:19:03 -0300 (ADT) Received: by qproxy.gmail.com with SMTP id v40so23300qbe for ; Wed, 19 Oct 2005 00:19:05 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=RaHJ+iokc78r4xDvoO7SMCFqAXnBzIOlTcClRGKL+H+1MUceOapKkqZZFTwpmmZoQ3ZNOP8dRPy/yLo1gB7/ANhjmYmR2qsrGhWKk2VdpqqWHY93YRumcB5+Zv9rJkT/n1/TJzrVlbub1yN8z5gmCXmOZg+/dv+FhTMdcsHx+xI= Received: by 10.65.188.4 with SMTP id q4mr255509qbp; Wed, 19 Oct 2005 00:19:05 -0700 (PDT) Received: by 10.64.232.11 with HTTP; Wed, 19 Oct 2005 00:19:04 -0700 (PDT) Message-ID: Date: Wed, 19 Oct 2005 08:19:04 +0100 From: Peter Childs To: pgsql-performance@postgresql.org Subject: Re: Inefficient escape codes. In-Reply-To: <20051018204727.GA29110@winnie.fuhr.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3cf983d0510181107sb060171je702da5fe0c29252@mail.gmail.com> <20051018190324.GA92715@winnie.fuhr.org> <3cf983d0510181209v3070a81dw9b21d4d09cbb5022@mail.gmail.com> <20051018204727.GA29110@winnie.fuhr.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.856 required=5 tests=[RCVD_BY_IP=0.024, RCVD_IN_BL_SPAMCOP_NET=1.832] X-Spam-Level: * X-Archive-Number: 200510/269 X-Sequence-Number: 15037 On 18/10/05, Michael Fuhr wrote: > [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. > You could base64 encode your data admitiaddly increasing it by 1/3 but it does at least convert it to text which means that its more unserstandable. base64 is also pritty standard being whats used in EMails for mime attachments. Peter