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: Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Date: Tue, 12 Jan 2016 12:11:53 +0100
Message-ID: <n72n1r$lto$1@ger.gmane.org> (raw)
In-Reply-To: <CAB=Je-Gbf2huAsXcfJs47uZJqeMZPutftswoKvvWb2weaDhTGA@mail.gmail.com>
References: <n708gj$348$1@ger.gmane.org>
	<CAB=Je-FWxz+vQQaXLS7kP1rzCFVjdVVJg+vzq7DDF66ASddy8Q@mail.gmail.com>
	<n70912$ap6$1@ger.gmane.org>
	<CAB=Je-Ea77aCTYVQPURxuDV34099ZotXGstC5kXbvhaLq4yYmQ@mail.gmail.com>
	<CAAQEOtxyXLt-asBtYE8GY-+MjdeOhp=1o+0YVOqmLjxD4EzsgQ@mail.gmail.com>
	<CADK3HHJgd4YJyh4qjxouBg=dPc463fiUjUjDOkgkeQq-bqqDJQ@mail.gmail.com>
	<CAB=Je-Gp2NmGs5KDBwUGL36UGko8x89n=VQjLS+u2GYSKwjKSA@mail.gmail.com>
	<CADK3HH+GZa+USn1iD_DCoVPF0k8WiM9R6Ms6moV_EbC2fwusLg@mail.gmail.com>
	<n70f5b$j8k$1@ger.gmane.org>
	<CADK3HHJFGjNXJns4exfw_NMGvKAR-1g2RTwvHcbVKK65kuHgEg@mail.gmail.com>
	<n72fhe$cf8$1@ger.gmane.org>
	<CAB=Je-Gbf2huAsXcfJs47uZJqeMZPutftswoKvvWb2weaDhTGA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Vladimir Sitnikov schrieb am 12.01.2016 um 11:44:
>> And then suddenly the runtime shoots through the rough going up from 1ms to 40ms or even 60ms
> 
> Can it be data-dependent?

Apparently the server chooses a bad execution plan when a server side prepared 
statement is used - it is very likely because of the parameter placeholders 
that don't allow Postgres to evaluate the correct cardinality and it 
creates a "one size fits all plan"

My guess is that the plan that is generated using the prepared statement only 
works for some input values, but not for all (a problem that Oracle has suffered 
from for ages as well). As I have written previously we didn't bother to enable the 
auto-explain module to see where Postgres goes wrong in the planning because using 
prepareThreshold=0 is good enough for us. 

Given my experience with bad plans for parametrized statements in Oracle I think it is 
definitely the better choice to not use server side prepared statements - at least for 
this application. 

> Can you try using the same input values for multiple executions?

The tests we are running are pretty much pre-defined. Re-working them would probably be a bigger deal.
Plus I am not directly involved in that project, so I am actually relaying everything here ;)

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: <n72n1r$lto$1@ger.gmane.org>
Permalink:  ../n72n1r$lto$1@ger.gmane.org/
Also on:    postgresql.org/message-id/n72n1r$lto$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: <n72n1r$lto$1@ger.gmane.org>
  References: <n708gj$348$1@ger.gmane.org> <CAB=Je-FWxz+vQQaXLS7kP1rzCFVjdVVJg+vzq7DDF66ASddy8Q@mail.gmail.com> <n70912$ap6$1@ger.gmane.org> <CAB=Je-Ea77aCTYVQPURxuDV34099ZotXGstC5kXbvhaLq4yYmQ@mail.gmail.com> <CAAQEOtxyXLt-asBtYE8GY-+MjdeOhp=1o+0YVOqmLjxD4EzsgQ@mail.gmail.com> <CADK3HHJgd4YJyh4qjxouBg=dPc463fiUjUjDOkgkeQq-bqqDJQ@mail.gmail.com> <CAB=Je-Gp2NmGs5KDBwUGL36UGko8x89n=VQjLS+u2GYSKwjKSA@mail.gmail.com> <CADK3HH+GZa+USn1iD_DCoVPF0k8WiM9R6Ms6moV_EbC2fwusLg@mail.gmail.com> <n70f5b$j8k$1@ger.gmane.org> <CADK3HHJFGjNXJns4exfw_NMGvKAR-1g2RTwvHcbVKK65kuHgEg@mail.gmail.com> <n72fhe$cf8$1@ger.gmane.org> <CAB=Je-Gbf2huAsXcfJs47uZJqeMZPutftswoKvvWb2weaDhTGA@mail.gmail.com> <n72n1r$lto$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