Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UiJwZ-0003Aq-BI for pgsql-performance@arkaria.postgresql.org; Fri, 31 May 2013 07:40:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UiJwY-00010p-MO for pgsql-performance@arkaria.postgresql.org; Fri, 31 May 2013 07:40:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UiJwX-00010e-Ft for pgsql-performance@postgresql.org; Fri, 31 May 2013 07:40:09 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UiJwP-0001Br-Sx for pgsql-performance@postgresql.org; Fri, 31 May 2013 07:40:09 +0000 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BCK77059; Fri, 31 May 2013 15:39:41 +0800 (CST) Received: from SZXEML416-HUB.china.huawei.com (10.82.67.155) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.1.323.7; Fri, 31 May 2013 15:39:05 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml416-hub.china.huawei.com (10.82.67.155) with Microsoft SMTP Server id 14.1.323.7; Fri, 31 May 2013 15:39:02 +0800 From: Amit Kapila To: "'Josh Berkus'" CC: References: <51A699E6.3000008@agliodbs.com> <00b301ce5d3d$697449a0$3c5cdce0$@kapila@huawei.com> <51A79512.4020200@agliodbs.com> In-Reply-To: <51A79512.4020200@agliodbs.com> Subject: Re: Performance bug in prepared statement binding in 9.2? Date: Fri, 31 May 2013 13:09:01 +0530 Message-ID: <000601ce5dd1$ec1d6320$c4582960$@kapila@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac5dYGHWaK21TqCTRta7LjF23F018gAYRsXQ Content-Language: en-us X-Originating-IP: [10.18.96.98] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Thursday, May 30, 2013 11:36 PM Josh Berkus wrote: > Amit, >=20 > > I think it might be because of choosing custom plan option due to > which it might be generating new plan during exec_bind_message(). > > exec_bind_message()->GetCachedPlan()->choose_custom_plan(). If it > chooses custom plan, then it will regenerate the plan which can cause > extra cost > > observed in test. > > Though there is calculation that it should not choose custom plan > always, but still I guess the variation observed in the test can be due > to this reason. >=20 > This is why I'm asking them to run tests on 9.1. If 9.1 doesn't > exhibit > this behavior, then customplan is liable to be at fault. >=20 > HOWEVER, that doesn't explain why creating a plan for a query during > application operation would take 80ms, but only 1.2ms when I do it > interactively. When you say interactively, does it mean that you are using psql to test th= e same? > FYI, per questions from IRC: the times for each "cycle" in my data are > cumulative minutes. Each cycle runs around 500,000 queries, so that's > the aggregate across all queries. Today I tried to see the changes between 8.4 and 9.1 for bind path in serve= r. Following is summary of whatever I could see the differences 1. 4 new parameters are added to ParamListInfo, for which palloc is done in= exec_bind_message 2. changed function for converting client to server encoding, but it seems = for bind path, it will still follow same path as for 8.4 2. small change in RevalidateCachedPlan() for new hook added in ParamListIn= fo 3. standard_ExecutorStart(), changes to setup After Statement Trigger conte= xt 4. InitPlan has some changes for FOR UPDATE/FOR SELECT statements and junk = filter case (update/delete statements)