Speed up JDBC connection creation on 9.0+

From: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
To: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Speed up JDBC connection creation on 9.0+
Date: 2014-04-18 23:28:40
Message-ID: CAH7T-arP9+Gq8OHMkkAA4Mkh-+7QS+LbXT0OweghCpi5_ZQxHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I submitted a pull request[1] that speeds up connection creation when
connection to a 9.0+ database. The idea is that if you instruct the
driver in advance that the remote server is 9.0+ then it can send the
"application_data" and "extra_float_digits" parameters as part of the
StartupMessage rather than in separate "SET ..." statements
afterwards. This saves a couple of round trips when creating a new
JDBC connection.

It probably won't make much difference for most people as if you're
using a connection pool the startup cost only happens once but it does
help a little bit.

For lack of a better name I've called the new boolean connection
property "isModernServer". Feel free to suggest a better name.

Thinking about it a bit more, if 8.4 is going to be EOL this year then
would it make more sense to skip this idea and just wait till it's
gone?

At that point we could have newer versions the JDBC driver (say a 9.4
release) assume the remote server is 9.0+ and not even bother with the
additional connection property.

We could even do the reverse and have a property instruct the driver
that the server is <9.0 so it doesn't send the application_name
property in the StartupMessage. Anyone upgrading to the latest driver
but using an older (EOLed) database would have to add the extra
property for compatibility but everybody else using 9.0+ servers would
get the faster startup without any config changes.

If that's acceptable then I think it's a better approach.

[1]: https://github.com/pgjdbc/pgjdbc/pull/144

Regards,
-- Sehrope Sarkuni
Founder & CEO | JackDB, Inc. | http://www.jackdb.com/

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gavin Flower 2014-04-18 23:56:21 Re: Speed up JDBC connection creation on 9.0+
Previous Message Bruce Momjian 2014-04-18 19:21:32 Re: BUG #8842: lo_open/fastpath transaction inconsistency