Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 26C3F9FB9BD for ; Fri, 25 May 2007 19:27:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 94277-05 for ; Fri, 25 May 2007 19:27:07 -0300 (ADT) X-Greylist: delayed 13:29:58.580971 by SQLgrey-1.7.5 Received: from server.gdfi.pl (fal94.internetdsl.tpnet.pl [83.13.11.94]) by postgresql.org (Postfix) with ESMTP id 23A3B9FB3D2 for ; Fri, 25 May 2007 19:27:07 -0300 (ADT) Received: from chello089076150099.chello.pl ([89.76.150.99] helo=[192.168.0.199]) by server.gdfi.pl with esmtpa (Exim 4.63) (envelope-from ) id 1HriFQ-0000Zu-Oo; Sat, 26 May 2007 00:27:01 +0200 Message-ID: <465762B6.3080608@datera.pl> Date: Sat, 26 May 2007 00:27:02 +0200 From: Michal Szymanski User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Tom Lane CC: pgsql-performance@postgresql.org Subject: Re: Big problem with sql update operation References: <4656A4E0.7020400@datera.pl> <8751.1180103318@sss.pgh.pa.us> In-Reply-To: <8751.1180103318@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/543 X-Sequence-Number: 24933 Tom Lane wrote: > 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. > > Real application modifiy every time modify different row. > (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.) > > There is another strange thing. We have two versions of our test environment one with production DB copy and second genereated with minimal data set and it is odd that update presented above on copy of production is executing 170ms but on small DB it executing 6s !!!! Michal Szymanski http://blog.szymanskich.net