From: Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
To: Nicholas White <n.j.white@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Patch: Force Primitives
Date: Mon, 25 Mar 2013 20:43:38 +0200
Message-ID: <51509ADA.6080602@nitorcreations.com> (raw)
In-Reply-To: <CA+=vxNZ9K7J+Pay-WqKtTsG0PTf2hxchfyX6ZQHWHtwdNuz-3g@mail.gmail.com>
References: <CA+=vxNbFOFq_24NASd6abQhY8AAwWfOYLQB7mAGMXNkOSzYJQQ@mail.gmail.com>
<CA+=vxNZtH+coKeFC4X6wE3vay7FsJZRYu0ZGDpaxK6O-qz9MYg@mail.gmail.com>
<51508849.40007@nitorcreations.com>
<CA+=vxNZ9K7J+Pay-WqKtTsG0PTf2hxchfyX6ZQHWHtwdNuz-3g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
On 03/25/2013 08:24 PM, Nicholas White wrote:
> > Do you see the binary transfers activating for array receives if you run your prepared statement select in a loop?
> That's the behaviour I see, athough something's setting my m_prepareThreshold to 5 rather than 3. I'm essentially using postgres as a persistent cache for my
> application server; when my app server starts it loads large amounts of data from postgres using a series of select-*-from-x queries. In order to minimise
> network I/O I'd ideally like a way to ensure I'm using the binary protocol from the very first query. Should I submit another patch that lets you configure this
> behaviour (either via a new JDBCUrl parameter or whether binaryTransfer is explicitly specified)?
I can't remember how the prepareTheshold goes. Is it so that even setting it to 1 (0 disables them) you still get real prepared statements (and at the same
time binary transfers) on the second execution. If you have an application that benefits from binary transfers on the first execution then yes, we should add
an option to enable that behaviour. So another patch for that would be nice.
> Separately, do you know why this behaviour is the default? Is the binary encoding more expensive (either server-side or client-side) than text encoding the data?
It's not because of binary encoding, which is faster on both server and client side.
The current functionality tries to avoid the extra describe overhead (is it even a roundtrip?) for prepared statements that are only executed once (or very few
times), which is quite common in many applications that seem to use prepared statements also for one-shot cases.
PS. if you are concerned about binary array transfer performance I did some work last year to optimize the protocol for arrays that do not contain nulls.
Unfortunately there was never any resolution to the server side patches. The discussion got stuck on weather updates with feature flags, adding a minor version
number to the protocol or just wait for pg 10 to break the protocol is the correct way to go forward.
You can grab the server side + jdbc patches from here: http://www.postgresql.org/message-id/4ECC186A.30709@nitorcreations.com
-Mikko
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: mikko.tiihonen@nitorcreations.com, n.j.white@gmail.com
Subject: Re: Patch: Force Primitives
In-Reply-To: <51509ADA.6080602@nitorcreations.com>
References: <CA+=vxNbFOFq_24NASd6abQhY8AAwWfOYLQB7mAGMXNkOSzYJQQ@mail.gmail.com> <CA+=vxNZtH+coKeFC4X6wE3vay7FsJZRYu0ZGDpaxK6O-qz9MYg@mail.gmail.com> <51508849.40007@nitorcreations.com> <CA+=vxNZ9K7J+Pay-WqKtTsG0PTf2hxchfyX6ZQHWHtwdNuz-3g@mail.gmail.com> <51509ADA.6080602@nitorcreations.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