Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 013EA650E82 for ; Thu, 26 Jun 2008 09:19:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 14572-06 for ; Thu, 26 Jun 2008 09:19:06 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id 8C32D650EAF for ; Thu, 26 Jun 2008 09:19:11 -0300 (ADT) thread-index: AcjXhvI+szG+JaVRSli7ED5lK8ZDmw== Content-Class: urn:content-classes:message Importance: normal Received: from [80.222.70.18] ([80.222.70.18]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 26 Jun 2008 08:19:56 -0400 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Message-ID: <48638939.5080500@enterprisedb.com> Date: Thu, 26 Jun 2008 15:19:05 +0300 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: "jay" Cc: Subject: Re: ??: Postgresql update op is very very slow References: <473587.97248.qm@web32701.mail.mud.yahoo.com> <004b01c8d671$3dec1630$0544000a@hz.ali.com> <486219B6.7050003@enterprisedb.com> <005101c8d773$ff81b2c0$0644000a@hz.ali.com> In-Reply-To: <005101c8d773$ff81b2c0$0644000a@hz.ali.com> Content-Type: text/plain; format=flowed; charset="UTF-8" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Jun 2008 12:19:56.0859 (UTC) FILETIME=[F22B90B0:01C8D786] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/163 X-Sequence-Number: 30513 jay wrote: > I know the problem, because there are about 35 million rows , which > cost about 12G disk space and checkpoint segments use 64, but update > operation is in one transaction which lead fast fill up the checkpoint > segments and lead do checkpoints frequently, but checkpoints will cost lots > resources, so update operation become slowly and slowly and bgwrite won't > write because it's not commit yet. > Create a new table maybe a quick solution, but it's not appropriated in some > cases. > If we can do commit very 1000 row per round, it may resolve the > problem. Committing more frequently won't help you with checkpoints. The updates will generate just as much WAL regardless of how often you commit, so you will have to checkpoint just as often. And commits have no effect on bgwriter either; bgwriter will write just as much regardless of how often you commit. One idea would be to partition the table vertically, that is, split the table into two tables, so that the columns that you need to update like that are in one table, together with the primary key, and the rest of the columns are in another table. That way the update won't need to scan or write the columns that are not changed. You can create a view on top of the two tables to make them look like the original table to the application. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com