pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedResultSet.getBinaryStream nothing more than a ResultSet.getBytes() call?
2+ messages / 2 participants
[nested] [flat]
* ResultSet.getBinaryStream nothing more than a ResultSet.getBytes() call?
@ 2004-10-04 23:17 Jeffrey Tenny <jeffrey.tenny@comcast.net>
0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey Tenny @ 2004-10-04 23:17 UTC (permalink / raw)
To: pgsql-jdbc
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.
Anybody got an authoritative answer? Or if you point me at a 8.0DEV
driver tarball I'll look myself, but I don't run CVS and couldn't find a
tarball on gborg.
TRACE 18107:
org.postgresql.util.PGbytea.toBytes(PGbytea.java:29)
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBytes(AbstractJdbc2ResultSet.java:1986)
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBinaryStream(AbstractJdbc2ResultSet.java:2115)
org.apache.commons.dbcp.DelegatingResultSet.getBinaryStream(DelegatingResultSet.java:221)
Thanks...
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes()
@ 2004-10-04 23:39 Oliver Jowett <oliver@opencloud.com>
parent: Jeffrey Tenny <jeffrey.tenny@comcast.net>
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Jowett @ 2004-10-04 23:39 UTC (permalink / raw)
To: Jeffrey Tenny <jeffrey.tenny@comcast.net>; +Cc: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-10-04 23:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-04 23:17 ResultSet.getBinaryStream nothing more than a ResultSet.getBytes() call? Jeffrey Tenny <jeffrey.tenny@comcast.net>
2004-10-04 23:39 ` Re: ResultSet.getBinaryStream nothing more than a ResultSet.getBytes() Oliver Jowett <oliver@opencloud.com>
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