X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43089329F1F for ; Tue, 5 Oct 2004 00:39:32 +0100 (BST) 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 02892-02 for ; Mon, 4 Oct 2004 23:39:26 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 9C8F0329F1E for ; Tue, 5 Oct 2004 00:39:26 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CEcQO-0002n4-00; Tue, 05 Oct 2004 12:39:24 +1300 Message-ID: <4161DF2A.6010408@opencloud.com> Date: Tue, 05 Oct 2004 12:39:22 +1300 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeffrey Tenny Cc: postgres jdbc Subject: Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes() References: <4161D9EF.9030202@comcast.net> In-Reply-To: <4161D9EF.9030202@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/6 X-Sequence-Number: 11111 Jeffrey Tenny wrote: > I've been working to minimize the memory footprint of my application. > I was under the impression that ResultSet.getBinaryStream would be more > efficient than getBytes(). Certainly the documented semantics imply > that that is a goal (since you must process the InputStream from > getBinaryStream before the call to ResultSet.next() or even processing > the next column. > > But the following trace from a java heap profile suggests > that we're still just copying the bytes from the resultset as with > getBytes() instead > of streaming the ones already in memory, though perhaps it's because > I'm using a read(buf) call on the stream. The intermediate copy happens because the "in memory" version is a text-escaped representation of the bytea value, not just a straight bytearray. getBinaryStream() could indeed be smarter, avoiding the intermediate bytearray by decoding the text representation on demand. But noone has implemented this yet. Probably a better long-term solution is to move to binary-format results at the protocol level. That's somewhere on my todo list, but I'm not making much progress on it at the moment. -O