pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Date: Mon, 11 Jan 2016 13:51:31 +0100
Message-ID: <n708gj$348$1@ger.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hello,

we have switched the Postgres JDBC driver from 9.2-1102 to 9.4-1207 to keep up-to-date.

After we did this our nightly regression tests that test for performance failed 
because with the new driver the tests were roughly 30% slower than with 
the previous driver (some of them even more than 30%). 

After enabling pg_stat_statements in your test environment we found out that some 
statements read a *much* higher number of blocks for the query.

Some sample figures (from pg_stat_statements)

One statement:

1102: 710 executions, total time:   845ms, shared_blks_hit =   624765
1207: 710 executions, total time: 30538ms, shared_blks_hit = 15046689

Another one:

1102: 8600 executions, total_time:   68ms, shared_blks_hit =   49500
1102: 8600 executions, total_time: 4035ms, shared_blks_hit = 3419644

The tests have been run against Postgres 9.4.5. 

As the tests don't involve any DML, table bloat could be excluded for a reason why 
the number of blocks is so high. 

It does not affect *all* statements - some statements (also with execution counts 
substantially larger than 200) run with the same performance.

So we assumed it had something to do with the execution plans, and the only way 
the driver could influence that (while the statement being exactly the same), 
was through the server side prepared statements. 

So we ran the tests using "prepareThreshold=0" and then the tests with 1207 
ran with the same performance as with the 1102 driver. 

We have not yet looked at the actual execution plans (e.g. by enabling the 
auto-explain module) because using "prepareThreshold=0" is fine for us for now.

So my question is: 

Is it possible that the 1207 driver does something different when preparing statements 
compared to 1102 that would cause Postgres to use a completely different execution plan?

The 9.3 driver behaves like the 9.2 driver, so the change probably occurred from 9.2 to 9.4
(we didn't test all the 9.4 builds, only the latest)

Regards
Thomas




-- 
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 (72+ messages)  latest in thread

Message-ID: <n708gj$348$1@ger.gmane.org>
Permalink:  ../n708gj$348$1@ger.gmane.org/
Also on:    postgresql.org/message-id/n708gj$348$1@ger.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
  In-Reply-To: <n708gj$348$1@ger.gmane.org>
  References: <n708gj$348$1@ger.gmane.org>

* 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