Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uci9o-0003ov-OU for pgsql-bugs@arkaria.postgresql.org; Wed, 15 May 2013 20:18:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Uci9o-0001y7-7W for pgsql-bugs@arkaria.postgresql.org; Wed, 15 May 2013 20:18:40 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uci9n-0001xM-0p for pgsql-bugs@postgresql.org; Wed, 15 May 2013 20:18:39 +0000 Received: from mxout.myoutlookonline.com ([64.95.72.252]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uci9k-0002jM-NO for pgsql-bugs@postgresql.org; Wed, 15 May 2013 20:18:38 +0000 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 623638BEDD6; Wed, 15 May 2013 15:53:08 -0400 (EDT) X-Virus-Scanned: by SpamTitan at mail.lan Received: from S10HUB001.SH10.lan (unknown [10.110.2.1]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mxout.myoutlookonline.com (Postfix) with ESMTPS id D90D18BF4E2; Wed, 15 May 2013 15:53:07 -0400 (EDT) Received: from S10HUBR001.SH10.lan (10.110.133.100) by S10HUB001.SH10.lan (10.110.133.11) with Microsoft SMTP Server (TLS) id 14.1.438.0; Wed, 15 May 2013 16:17:29 -0400 Received: from tcook2.blackducksoftware.com (208.177.254.126) by mail10.myoutlookonline.com (10.110.133.100) with Microsoft SMTP Server id 14.1.438.0; Wed, 15 May 2013 16:17:30 -0400 Message-ID: <5193ED59.1050209@blackducksoftware.com> Date: Wed, 15 May 2013 16:17:29 -0400 From: "Todd A. Cook" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Lane CC: Subject: Re: BUG #8163: simultaneous nearly identical update queries execute extremely slowly References: <5193E3B7.3070102@blackducksoftware.com> <18579.1368648648@sss.pgh.pa.us> In-Reply-To: <18579.1368648648@sss.pgh.pa.us> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [208.177.254.126] X-MS-Exchange-Transport-Rules-Loop: 0 X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 05/15/13 16:10, Tom Lane wrote: > "Todd A. Cook" writes: >> On 05/15/13 13:27, tcook@blackducksoftware.com wrote: >>> When nearly identical update queries arrive simultaneously, the first one to >>> execute runs normally, but subsequent executions run _extremely_ slowly. >>> We've seen this behaviour in production, and the contrived test case below >>> reproduces the issue. > >> I've repeated the test below on a 9.1.9 installation, and it works fine there. > > Given the reference to EvalPlanQual in your stack trace, I'm thinking > the explanation is this 9.0 fix: Thanks for the explanation. Is there any chance of that fix being backpatched into 8.4? -- todd > Author: Tom Lane > Branch: master Release: REL9_0_BR [9f2ee8f28] 2009-10-26 02:26:45 +0000 > > Re-implement EvalPlanQual processing to improve its performance and eliminate > a lot of strange behaviors that occurred in join cases. We now identify the > "current" row for every joined relation in UPDATE, DELETE, and SELECT FOR > UPDATE/SHARE queries. If an EvalPlanQual recheck is necessary, we jam the > appropriate row into each scan node in the rechecking plan, forcing it to emit > only that one row. The former behavior could rescan the whole of each joined > relation for each recheck, which was terrible for performance, and what's much > worse could result in duplicated output tuples. > > Also, the original implementation of EvalPlanQual could not re-use the recheck > execution tree --- it had to go through a full executor init and shutdown for > every row to be tested. To avoid this overhead, I've associated a special > runtime Param with each LockRows or ModifyTable plan node, and arranged to > make every scan node below such a node depend on that Param. Thus, by > signaling a change in that Param, the EPQ machinery can just rescan the > already-built test plan. > > This patch also adds a prohibition on set-returning functions in the > targetlist of SELECT FOR UPDATE/SHARE. This is needed to avoid the > duplicate-output-tuple problem. It seems fairly reasonable since the > other restrictions on SELECT FOR UPDATE are meant to ensure that there > is a unique correspondence between source tuples and result tuples, > which an output SRF destroys as much as anything else does. > > regards, tom lane > > -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs