Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aIxrJ-0002al-QQ for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jan 2016 12:15:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aIxrJ-0005XC-C4 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jan 2016 12:15:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aIxrH-0005VY-9P for pgsql-hackers@postgresql.org; Tue, 12 Jan 2016 12:15:31 +0000 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aIxrE-0006ck-KY for pgsql-hackers@postgresql.org; Tue, 12 Jan 2016 12:15:29 +0000 Received: by mail-lb0-x22e.google.com with SMTP id x4so14369351lbm.0 for ; Tue, 12 Jan 2016 04:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joh-to.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=Cwb9aS8IOGDanl6ncdo+ualgGNQXmEJHgL1yhcssuwg=; b=dcsitaoHMDjyWuJT4XB5IMIs2zjKJLw4I/BmF29B+9EOKhUROWyjKaesZvCmdSaTe8 FFjUhT9juIG2oZ5XZyB1arl1+VW5mT2xXnIrK7kDpt821di8u6bkCj/rvAgvKrV+Ro2w EdNPRB1AsCBwmsKlZ1ETkAzaq6+6W6Y0F2OJePXh0JN+GaQTfa88rDH5WBueOgCkUAxq xn6uxtfDMpSxw7KS6ER12RV8GVaG+TBnuV1sXbzvdkF3+v1nRlZl45kuX+vJ7LYUbB6C GEMUZwMd7zTFVcgmrHz6AEDA3e796XuDq7byt1rJ2ikyODNqxwS2ZSfzbdv5SBEFQaUp P2wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=Cwb9aS8IOGDanl6ncdo+ualgGNQXmEJHgL1yhcssuwg=; b=iT7hOoU/SyzdgDYQ4xIhUwdP5lGNfoFFPtQO8VZiR7i5PlSipfoBKMRHQA2ggPE6gs PdArJlx1b0idkkN4ST2EaPoZHr5RI4iF57jLJvquKB06BLmXhX5fbSmw+Ii7ok55tNJk 4mnr4TIXDWq6N3Uf0VqhztRm/5ourZsEN5jWhaySjDL0rJ1JORgjvcf4HmECDEttlpn0 GcOo53n343TLAV6JxclmpsT01CadFAQNNteBPiP4gLJWHW3Z0haRDryLLORoUMKBaH4F isJB9T+UvgAztIZPQrxYFB2WVOzkG99weNT9RhWsRI88Q81CRNbrISGqmPMs1XT44ZrS VT6A== X-Gm-Message-State: ALoCoQmdt8KgjL5W1j9sNPR2SfMhKeKZ9sOLcTCt1m/uCwCLwMqBw7KcyeFP/bvOT56S8N0pjZAcpZT0QyQhYKUXcXxmL/dEow== X-Received: by 10.112.77.8 with SMTP id o8mr36709500lbw.53.1452600925016; Tue, 12 Jan 2016 04:15:25 -0800 (PST) Received: from Markos-MacBook-Pro.local ([46.246.117.202]) by smtp.googlemail.com with ESMTPSA id rp10sm4763648lbb.13.2016.01.12.04.15.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jan 2016 04:15:24 -0800 (PST) Subject: Re: Fwd: [JDBC] Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102 To: Dave Cramer , PostgreSQL-development References: From: Marko Tiikkaja Message-ID: <5694EE5B.1030203@joh.to> Date: Tue, 12 Jan 2016 13:15:23 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 12/01/16 13:00, Dave Cramer wrote: > We have an interesting problem, and the reporter has been kind enough to > provide logs for which we can't explain. > > I'd be interested to hear any plausible explanations for a prepared plan > suddenly going from 2ms to 60ms for the same input values ? This is a new feature in 9.2, where on the fifth (or sixth, not sure) execution the planner might choose to use a generic plan. From the 9.2 release notes (though I'm fairly certain this is documented somewhere in the manual as well): In the past, a prepared statement always had a single "generic" plan that was used for all parameter values, which was frequently much inferior to the plans used for non-prepared statements containing explicit constant values. Now, the planner attempts to generate custom plans for specific parameter values. A generic plan will only be used after custom plans have repeatedly proven to provide no benefit. This change should eliminate the performance penalties formerly seen from use of prepared statements (including non-dynamic statements in PL/pgSQL). .m -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers