pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Jeffrey Tenny <jeffrey.tenny@comcast.net>
Cc: postgres jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes()
Date: Tue, 05 Oct 2004 12:39:22 +1300
Message-ID: <4161DF2A.6010408@opencloud.com> (raw)
In-Reply-To: <4161D9EF.9030202@comcast.net>
References: <4161D9EF.9030202@comcast.net>

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



view thread (2+ messages)

Message-ID: <4161DF2A.6010408@opencloud.com>
Permalink:  ../4161DF2A.6010408@opencloud.com/
Also on:    postgresql.org/message-id/4161DF2A.6010408@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, jeffrey.tenny@comcast.net
  Subject: Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes()
  In-Reply-To: <4161DF2A.6010408@opencloud.com>
  References: <4161D9EF.9030202@comcast.net> <4161DF2A.6010408@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox