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 1FB5D9DCC1B for ; Mon, 13 Feb 2006 22:14:36 -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 82692-06 for ; Mon, 13 Feb 2006 22:14:40 -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 D43EC9DC86C for ; Mon, 13 Feb 2006 22:14:33 -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 k1E2EYrg055989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Feb 2006 19:14:37 -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 k1E2EYQg075333; Mon, 13 Feb 2006 19:14:34 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1E2EYL4075332; Mon, 13 Feb 2006 19:14:34 -0700 (MST) (envelope-from mfuhr) Date: Mon, 13 Feb 2006 19:14:34 -0700 From: Michael Fuhr To: Ken Hill Cc: Postgres Help Subject: Re: Slow update SQL Message-ID: <20060214021434.GA75196@winnie.fuhr.org> References: <1139881725.3183.2.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1139881725.3183.2.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/145 X-Sequence-Number: 24155 On Mon, Feb 13, 2006 at 05:48:45PM -0800, Ken Hill wrote: > When I try to analyze the query plan with: > > EXPLAIN ANALYZE > UPDATE ncccr10 > SET key = facilityno||'-'|| > lastname||'-'|| > sex||'-'|| > ssno||'-'|| > birthdate||'-'|| > primarysit||'-'|| > dxdate||'-'|| > morphology3 > WHERE date_part('year',dxdate) > '2000'; > > The query just never finishes (even 1 hour later). The colum key100 is > indexed, and I'm setting the value of this > column from other columns. Why is this so slow? If EXPLAIN ANALYZE is taking too long then could we at least see the EXPLAIN output? How many rows does the condition match? SELECT count(*) FROM ncccr10 WHERE date_part('year',dxdate) > '2000'; Do you have an expression index on date_part('year',dxdate)? Does the table have any triggers or rules? Have you queried pg_locks to see if the update is blocked on an ungranted lock? Do other tables have foreign key references to ncccr10? If so then you might need indexes on the referring columns. What version of PostgreSQL are you running? -- Michael Fuhr