X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C591A52A5B for ; Sat, 5 Mar 2005 14:02:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51257-02 for ; Sat, 5 Mar 2005 14:02:19 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 07CE952A8B for ; Sat, 5 Mar 2005 14:02:18 +0000 (GMT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1D7Zkq-0001LL-Va for pgsql-sql@postgresql.org; Sat, 05 Mar 2005 14:55:41 +0100 Received: from p54a25c36.dip.t-dialin.net ([84.162.92.54]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Mar 2005 14:55:40 +0100 Received: from news-exp-jul05 by p54a25c36.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Mar 2005 14:55:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Mueller Subject: Re: Simple delete takes hours Date: Sat, 05 Mar 2005 15:00:46 +0100 Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: p54a25c36.dip.t-dialin.net User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Enigmail-Version: 0.90.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-MailScanner-From: sql-pgsql-sql@m.gmane.org X-MailScanner-To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.673 tagged_above=0 required=5 tests=AWL, FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200503/77 X-Sequence-Number: 20556 On 05.03.2005 00:24 PFC wrote: > Every time a row is removed from pwd_name, the ON DELETE CASCADE > trigger will look in pwd_name_rev if there is a row to delete... Does > it have an index on pwd_name_rev( rev_of ) ? If not you'll get a full > table scan for every row deleted in pwd_name... Yes that's it, thanks a lot! pwdcheck=# explain analyze delete from pwd_name where description=1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- Seq Scan on pwd_name (cost=0.00..116571.15 rows=1774250 width=6) (actual time=9526.671..21957.920 rows=543348 loops=1) Filter: (description = 1) Total runtime: 35555.749 ms (3 rows) Is it possible to get fired triggers/called stored procedures and things like that in an 'explain' ? To find out why the delete is that slow I did: pwdcheck=# explain analyze delete from pwd_name where id in pwdcheck-# (select id from pwd_name where description=1 limit 10); There was no hint that every deleted row leads to a full table scan. Thomas