Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 533079FB688 for ; Fri, 25 May 2007 11:28:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 45522-09 for ; Fri, 25 May 2007 11:28:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C7D5D9FB6B9 for ; Fri, 25 May 2007 11:28:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l4PESchu008752; Fri, 25 May 2007 10:28:39 -0400 (EDT) To: Michal Szymanski cc: pgsql-performance@postgresql.org Subject: Re: Big problem with sql update operation In-reply-to: <4656A4E0.7020400@datera.pl> References: <4656A4E0.7020400@datera.pl> Comments: In-reply-to Michal Szymanski message dated "Fri, 25 May 2007 10:57:04 +0200" Date: Fri, 25 May 2007 10:28:38 -0400 Message-ID: <8751.1180103318@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/513 X-Sequence-Number: 24903 Michal Szymanski writes: > CREATE OR REPLACE FUNCTION test() > RETURNS void AS > $BODY$ > DECLARE > BEGIN > FOR v_i IN 1..4000 LOOP > UPDATE group_fin_account_tst SET > credit = v_i > WHERE group_fin_account_tst_id = 1; -- for real procedure I > update different rows Does updating the *same* record 4000 times per transaction reflect the real behavior of your application? If not, this is not a good benchmark. If so, consider redesigning your app to avoid so many redundant updates. (For the record, the reason you see nonlinear degradation is the accumulation of tentatively-dead versions of the row, each of which has to be rechecked by each later update.) regards, tom lane