Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Date: 2016-01-12 11:11:53
Message-ID: n72n1r$lto$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michal Novotny 2016-01-12 11:14:12 Re: Question about DROP TABLE
Previous Message Andres Freund 2016-01-12 11:05:04 Re: Question about DROP TABLE

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vladimir Sitnikov 2016-01-12 11:26:27 Re: Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Previous Message Vladimir Sitnikov 2016-01-12 10:44:07 Re: Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102