Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aIwsQ-0006ia-7t for pgsql-jdbc@arkaria.postgresql.org; Tue, 12 Jan 2016 11:12:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aIwsP-000711-QO for pgsql-jdbc@arkaria.postgresql.org; Tue, 12 Jan 2016 11:12:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aIwrv-0006Sn-4o for pgsql-jdbc@postgresql.org; Tue, 12 Jan 2016 11:12:07 +0000 Received: from plane.gmane.org ([80.91.229.3]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aIwrr-0005hB-OL for pgsql-jdbc@postgresql.org; Tue, 12 Jan 2016 11:12:06 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aIwrq-0004wl-CT for pgsql-jdbc@postgresql.org; Tue, 12 Jan 2016 12:12:02 +0100 Received: from 185.40.248.10 ([185.40.248.10]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Jan 2016 12:12:02 +0100 Received: from spam_eater by 185.40.248.10 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Jan 2016 12:12:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer 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 Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 185.40.248.10 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: X-Pg-Spam-Score: 0.4 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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