X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 232419DC8AD for ; Tue, 14 Feb 2006 01:17:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21562-04 for ; Tue, 14 Feb 2006 01:17:27 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id B47909DC8A2 for ; Tue, 14 Feb 2006 01:17:25 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k1E5HMuv056127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Feb 2006 22:17:24 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k1E5HML0076554; Mon, 13 Feb 2006 22:17:22 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1E5HLO4076553; Mon, 13 Feb 2006 22:17:21 -0700 (MST) (envelope-from mfuhr) Date: Mon, 13 Feb 2006 22:17:21 -0700 From: Michael Fuhr To: Ken Hill Cc: pgsql-sql@postgresql.org Subject: Re: Slow update SQL Message-ID: <20060214051721.GA76364@winnie.fuhr.org> References: <1139881725.3183.2.camel@localhost.localdomain> <20060214021434.GA75196@winnie.fuhr.org> <1139885286.3183.10.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1139885286.3183.10.camel@localhost.localdomain> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/147 X-Sequence-Number: 24157 [Please copy the mailing list on replies.] On Mon, Feb 13, 2006 at 06:48:06PM -0800, Ken Hill wrote: > On Mon, 2006-02-13 at 19:14 -0700, Michael Fuhr wrote: > > How many rows does the condition match? > > csalgorithm=# SELECT count(*) FROM ncccr10 WHERE > date_part('year',dxdate) > '2000'; > count > -------- > 199209 > (1 row) You're updating about a third of the table; an expression index on date_part probably wouldn't help because the planner is likely to stick with a sequential scan for such a large update. Even if it did help it's likely to be a small fraction of the total time. The table definition you sent me showed nine indexes. You might see a substantial performance improvement by dropping all the indexes, doing the update, then creating the indexes again (don't forget to vacuum and analyze the table after the update). However, dropping the indexes has obvious implications for other queries so you might need to do the update at a time when that doesn't matter. > > Have you queried pg_locks > > to see if the update is blocked on an ungranted lock? > > I don't know what that is. How do I query pg_locks? SELECT * FROM pg_locks; http://www.postgresql.org/docs/7.4/static/monitoring-locks.html > > What version of PostgreSQL are you running? > > 7.4.8. Thank you for your help. Newer versions generally perform better; consider upgrading to 8.0 or 8.1 if possible. -- Michael Fuhr