Allow the first query of a prepared statement to use binary encoding #51

Merged
merged 1 commit into from Oct 16, 2013

Projects

None yet

3 participants

@njwhite
njwhite commented Apr 4, 2013

As described here - currently you can only do binary transfers from the second query of a prepared statement onwards.

@njwhite
njwhite commented Apr 17, 2013

The setPrepareThreshold of a PGStatement determines how many times the statement can be used before server-side preparation (and so the binary protocol) is used. Currently you can only make the second and subsequent queries use server-side prepares - my change means you can tell the PGStatement to make the first and subsequent queries use server-side prepare. This change is essentially a configuration change; the code path is already enabled. Thanks -

@davecramer
Member

This fails a number of tests on my machine

junit.framework.AssertionFailedError: expected:<0> but was:<1>
[junit] at org.postgresql.test.jdbc4.BinaryTest.testPreparedStatement_3(BinaryTest.java:47)

junit.framework.AssertionFailedError: expected:<0> but was:<1>
[junit] at org.postgresql.test.jdbc4.BinaryTest.testPreparedStatement_0(BinaryTest.java:79)

@davecramer
Member

If we can get the tests fixed we can merge this.

@njwhite
njwhite commented Jul 11, 2013

I've fixed the tests - the build.xml was changing the system properties that determines how the binary protocol is used. Thanks -

@njwhite
njwhite commented Jul 21, 2013

I've fixed the tests - is it OK now? Thanks -

Nick

@davecramer
Member

Nick,

I will get a chance to look at this in the next few days

Thanks,

Dave Cramer

On Sun, Jul 21, 2013 at 3:49 PM, njwhite notifications@github.com wrote:

I've fixed the tests - is it OK now? Thanks -

Nick


Reply to this email directly or view it on GitHubhttps://github.com/pgjdbc/pgjdbc/pull/51#issuecomment-21315717
.

@segasai
segasai commented Oct 16, 2013

Hi,

Any chance of merging this pull request ? I'm just dealing with large data intensive transfers from PostgreSQL (no queries are repeated) and the ASCII -> Java conversion takes a very large chunk of time in that case.
Forcing binary transfers for all the queries (via -Dorg.postgresql.forcebinary) seems to break something, so this patch seems to be the only way get better performance.

Thanks,
Sergey

@davecramer davecramer merged commit dbf76c2 into pgjdbc:master Oct 16, 2013
@segasai
segasai commented Oct 16, 2013

Thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment