From: Tom Lane <tgl@sss.pgh.pa.us>
To: Todd A. Cook <tcook@blackducksoftware.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8163: simultaneous nearly identical update queries execute extremely slowly
Date: Wed, 15 May 2013 16:10:48 -0400
Message-ID: <18579.1368648648@sss.pgh.pa.us> (raw)
In-Reply-To: <5193E3B7.3070102@blackducksoftware.com>
References: <E1UcfUU-0008C6-F7@wrigleys.postgresql.org>
<5193E3B7.3070102@blackducksoftware.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
"Todd A. Cook" <tcook@blackducksoftware.com> 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:
Author: Tom Lane <tgl@sss.pgh.pa.us>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, tcook@blackducksoftware.com
Subject: Re: BUG #8163: simultaneous nearly identical update queries execute extremely slowly
In-Reply-To: <18579.1368648648@sss.pgh.pa.us>
References: <E1UcfUU-0008C6-F7@wrigleys.postgresql.org> <5193E3B7.3070102@blackducksoftware.com> <18579.1368648648@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox