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 830C7555C6 for ; Fri, 4 Mar 2005 08:35:59 +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 79382-10 for ; Fri, 4 Mar 2005 08:35:56 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id D6FD655456 for ; Fri, 4 Mar 2005 08:35:54 +0000 (GMT) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1D78Cj-0006zh-PC for pgsql-sql@postgresql.org; Fri, 04 Mar 2005 09:30:37 +0100 Received: from p54a27ed4.dip.t-dialin.net ([84.162.126.212]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Mar 2005 09:30:37 +0100 Received: from news-exp-jul05 by p54a27ed4.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Mar 2005 09:30:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Mueller Subject: Simple delete takes hours Date: Thu, 03 Mar 2005 22:44:58 +0100 Lines: 48 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: p54a27ed4.dip.t-dialin.net User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) X-Accept-Language: de-DE, de, en-us, en X-Enigmail-Version: 0.90.0.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.934 tagged_above=0 required=5 tests=DATE_IN_PAST_06_12, FROM_ENDS_IN_NUMS, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200503/65 X-Sequence-Number: 20544 Hi there, I have a simple database: CREATE TABLE pwd_description ( id SERIAL NOT NULL UNIQUE PRIMARY KEY, name varchar(50) NOT NULL ); CREATE TABLE pwd_name ( id SERIAL NOT NULL UNIQUE PRIMARY KEY, description integer NOT NULL REFERENCES pwd_description(id), name varchar(50) NOT NULL, added timestamp DEFAULT now() ); CREATE TABLE pwd_name_rev ( id SERIAL NOT NULL UNIQUE PRIMARY KEY, description integer NOT NULL REFERENCES pwd_description(id), rev_of integer NOT NULL REFERENCES pwd_name(id) ON DELETE CASCADE, name varchar(50) NOT NULL ); The indexes shouldn't matter I think. pwd_name_rev is filled by a stored procedure and a trigger (ON INSERT) when something is inserted to pwd_name. Both tables contain about 4.500.000 emtries each. I stopped 'delete from pwd_name where description=1' after about 8 hours (!). The query should delete about 500.000 records. Then I tried 'delete from pwd_name_rev where description=1' - this took 23 seconds (!). Then I retried the delete on pwd_name but it's running for 6 hours now. I use PostgreSQL 7.4.7 on Linux 2.6.10. The machine is a Celeron 2 GHz with 512 MB RAM. PostgreSQL should do a full table scan I think, get all records with description=1 and remove them - I don't understand what's happening for >8 hours. Any help is appreciated. Thomas