X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2B6F79DC81F for ; Sun, 18 Dec 2005 22:36:19 -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 69908-07 for ; Sun, 18 Dec 2005 22:36:23 -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 E0A1C9DC859 for ; Sun, 18 Dec 2005 22:36:16 -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 jBJ2aGhv093308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 18 Dec 2005 19:36:19 -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 jBJ2aGwY089762; Sun, 18 Dec 2005 19:36:16 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id jBJ2aGwU089761; Sun, 18 Dec 2005 19:36:16 -0700 (MST) (envelope-from mfuhr) Date: Sun, 18 Dec 2005 19:36:16 -0700 From: Michael Fuhr To: James Klo Cc: pgsql-performance@postgresql.org Subject: Re: make bulk deletes faster? Message-ID: <20051219023616.GA89670@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.029 required=5 tests=[AWL=0.029] X-Spam-Score: 0.029 X-Spam-Level: X-Archive-Number: 200512/448 X-Sequence-Number: 16269 On Sat, Dec 17, 2005 at 09:10:40PM -0800, James Klo wrote: > I'd like some suggestions on how to get the deletes to happen faster, as > while deleting individually appears to extremely fast, when I go to > delete lots of rows the operation takes an extremely long time to > complete (5000 rows takes about 3 minutes, 1000000 rows takes almost > close to 4 hours or more depending upon server load; wall time btw). Those times do seem excessive -- do any other tables have foreign key references to the table you're deleting from? If so, do those tables have indexes on the referring columns? Does this table or any referring table have triggers? Also, are you regularly vacuuming and analyzing your tables? Have you examined pg_locks to see if an unacquired lock might be slowing things down? -- Michael Fuhr