X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7C5C7D7255 for ; Fri, 2 Sep 2005 10:36:15 -0300 (ADT) 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 29761-08 for ; Fri, 2 Sep 2005 13:36:14 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 6601DD7A3C for ; Fri, 2 Sep 2005 10:36:11 -0300 (ADT) 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 j82DaBx1029074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Sep 2005 07:36:14 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j82DaBD7065410; Fri, 2 Sep 2005 07:36:11 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j82DaAh7065409; Fri, 2 Sep 2005 07:36:10 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 2 Sep 2005 07:36:10 -0600 From: Michael Fuhr To: Arnau Cc: pgsql-performance@postgresql.org Subject: Re: Advise about how to delete entries Message-ID: <20050902133610.GB65294@winnie.fuhr.org> References: <43183AC9.1060704@andromeiberica.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43183AC9.1060704@andromeiberica.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/53 X-Sequence-Number: 14361 On Fri, Sep 02, 2005 at 01:43:05PM +0200, Arnau wrote: > > statistic_id | numeric(10,0) | not null default > nextval('STATISTICS_OPERATOR_ID_SEQ'::text) Any reason this column is numeric instead of integer or bigint? > That contains about 7.000.000 entries and I have to remove 33.000 > entries. I have created an sql file with all the delete sentences, e.g.: > > "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" > > then I do \i delete_items.sql. Remove a single entry takes more than 10 > seconds. What would you do to speed it up? The referential integrity triggers might be slowing down the delete. Do you have indexes on all foreign key columns that refer to this table? Do all foreign key columns that refer to statistic_id have the same type as statistic_id (numeric)? What's the output "EXPLAIN ANALYZE DELETE ..."? Do you vacuum and analyze the tables regularly? What version of PostgreSQL are you using? -- Michael Fuhr