Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 767719FBC96 for ; Mon, 4 Jun 2007 09:55:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 10650-04 for ; Mon, 4 Jun 2007 09:55:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from nabagan.bluegap.ch (nabagan.bluegap.ch [88.198.58.248]) by postgresql.org (Postfix) with ESMTP id 7CC339FBC74 for ; Mon, 4 Jun 2007 09:55:34 -0300 (ADT) Received: from [192.168.0.237] (berlin.programmfabrik.de [::ffff:213.221.101.147]) (AUTH: CRAM-MD5 markus@bluegap.ch, TLS: TLSv1/SSLv3, 256bits, AES256-SHA) by nabagan.bluegap.ch with esmtp; Mon, 04 Jun 2007 15:49:46 +0200 id 0070C3CE.4664187B.00004057 Message-ID: <46640B8F.8040503@bluegap.ch> Date: Mon, 04 Jun 2007 14:54:39 +0200 From: Markus Schiltknecht User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: "Miha D. Puc" CC: pgsql-interfaces@postgresql.org Subject: Re: Bytea network traffic: binary vs text result format References: <466299A7.20403@eba.si> In-Reply-To: <466299A7.20403@eba.si> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/2 X-Sequence-Number: 6571 Hi, Miha D. Puc wrote: > So there is a need (people asking) and reason (performance) to use > binary format. You are aware that PostgreSQL itself *can* transfer values in binary format? Check the Documentation: "43.1.3. Formats and Format Codes": http://www.postgresql.org/docs/8.1/interactive/protocol.html This works since protocol version 3, AFAICT. The client needs to support that, though. But the php pgsql binding, just as an example, doesn't use that feature. > So with all the above there should be a utility for conversion between > binary format and native types and/or string format in libpq. There already are. Not in libpq, though. Most (if not all) internal types have those functions. See for example: # SELECT typinput, typoutput, typreceive, typsend # FROM pg_type WHERE typname='int4'; typinput | typoutput | typreceive | typsend ----------+-----------+------------+---------- int4in | int4out | int4recv | int4send (1 row) The input and output functions deal with the textual representation, while send and receive convert to a binary representation in network byte order. Hope that helps. Regards Markus