pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Reuven M. Lerner <reuven@lerner.co.il>
To: Dave Cramer <pg@fastcrypt.com>
Cc: List <pgsql-jdbc@postgresql.org>
Cc: kim+pg@alleroedderne.adsl.dk
Subject: Re: Bound parameters on Linux are extremely slow (compared to unbound and/or Windows)
Date: Tue, 25 Jun 2013 15:43:38 +0300
Message-ID: <51C9907A.9030108@lerner.co.il> (raw)
In-Reply-To: <CADK3HHL0pEZB7-m+8MwHCHPr=RUvhY6jYrCKf1ZsjsGUUNXqcg@mail.gmail.com>
References: <51A14091.7040909@lerner.co.il>
	<CADK3HH+p-z3pyCmUCBqQysUP1ePU=s2sGvksMkZQ008mXNv0xQ@mail.gmail.com>
	<51A14769.1080409@lerner.co.il>
	<CADK3HH+A4RiLOhSRwaEFP1gTBRSEHeCxMsYG-cgDokigJ6wUgA@mail.gmail.com>
	<51A14D8C.7010201@lerner.co.il>
	<CADK3HHL0pEZB7-m+8MwHCHPr=RUvhY6jYrCKf1ZsjsGUUNXqcg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hi, everyone.  About a month ago, I e-mailed this list about a project 
I'm helping which is having hugely different performance results 
depending on whether they use Linux or Windows.  Several list members 
were nice enough to offer some answers, but then I disappeared for a 
while, thanks to travel + illness + family + crazy schedules.

Just to recap: We have an application written in Java.  When we build 
the SQL query manually, using a StringBuilder, we get similar results on 
Windows and Linux.  But when we use the JDBC driver's parameter 
bindings, we find wildly different performance.  Specifically:

With binding:
	Linux: 2,233 ms (yes, more than 2 seconds)
	Windows: 232 ms

Without binding:
	Linux: 176 ms
	Windows: 152 ms

The two test pieces of code, which we used to benchmark performance, and 
which work on the table we want to use in production, are at:

https://gist.github.com/reuven/5858095  # without bindings
https://gist.github.com/reuven/5858092  # with bindings

I believe that the tests were run on localhost, such that the client and 
server were both executing on the same computer.

When we execute the query manually, via psql, we get fast results, on 
both Windows and Linux.  Thus, it would seem that something in the 
parameter-binding code in the JDBC driver is somehow interacting poorly 
with Linux.

I'm far from a Java expert, and even less of a Windows guy, so I'm not 
sure what is going on here.  Any suggestions as to what we should be 
looking for, or tuning in the PostgreSQL and/or Windows configuration to 
avoid such problems?

Thanks again for any help that you can offer.

Reuven


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (14+ messages)  latest in thread

Message-ID: <51C9907A.9030108@lerner.co.il>
Permalink:  ../51C9907A.9030108@lerner.co.il/
Also on:    postgresql.org/message-id/51C9907A.9030108@lerner.co.il

 · 

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: reuven@lerner.co.il, pg@fastcrypt.com, kim+pg@alleroedderne.adsl.dk
  Subject: Re: Bound parameters on Linux are extremely slow (compared to unbound and/or Windows)
  In-Reply-To: <51C9907A.9030108@lerner.co.il>
  References: <51A14091.7040909@lerner.co.il> <CADK3HH+p-z3pyCmUCBqQysUP1ePU=s2sGvksMkZQ008mXNv0xQ@mail.gmail.com> <51A14769.1080409@lerner.co.il> <CADK3HH+A4RiLOhSRwaEFP1gTBRSEHeCxMsYG-cgDokigJ6wUgA@mail.gmail.com> <51A14D8C.7010201@lerner.co.il> <CADK3HHL0pEZB7-m+8MwHCHPr=RUvhY6jYrCKf1ZsjsGUUNXqcg@mail.gmail.com> <51C9907A.9030108@lerner.co.il>

* 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