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 D629AD8DD1 for ; Tue, 18 Oct 2005 17:47:34 -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 06272-10 for ; Tue, 18 Oct 2005 20:47:31 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id A5216D84C6 for ; Tue, 18 Oct 2005 17:47:32 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j9IKlStN093437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Oct 2005 14:47:31 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id j9IKlSLo029348; Tue, 18 Oct 2005 14:47:28 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id j9IKlR3Z029347; Tue, 18 Oct 2005 14:47:27 -0600 (MDT) (envelope-from mfuhr) Date: Tue, 18 Oct 2005 14:47:27 -0600 From: Michael Fuhr To: Rodrigo Madera Cc: pgsql-performance@postgresql.org Subject: Re: Inefficient escape codes. Message-ID: <20051018204727.GA29110@winnie.fuhr.org> Reply-To: pgsql-performance@postgresql.org References: <3cf983d0510181107sb060171je702da5fe0c29252@mail.gmail.com> <20051018190324.GA92715@winnie.fuhr.org> <3cf983d0510181209v3070a81dw9b21d4d09cbb5022@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3cf983d0510181209v3070a81dw9b21d4d09cbb5022@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/268 X-Sequence-Number: 15036 [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