Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes()

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Jeffrey Tenny <jeffrey(dot)tenny(at)comcast(dot)net>
Cc: postgres jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes()
Date: 2004-10-04 23:39:22
Message-ID: 4161DF2A.6010408@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Yamir Encarnacion 2004-10-04 23:54:33 Mangled accented characters
Previous Message Jeffrey Tenny 2004-10-04 23:17:03 ResultSet.getBinaryStream nothing more than a ResultSet.getBytes() call?