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 E0B6DD6E86 for ; Fri, 2 Sep 2005 08:43:10 -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 09350-06 for ; Fri, 2 Sep 2005 11:43:09 +0000 (GMT) Received: from mail.androme.com (mail.androme.com [62.58.96.145]) by svr1.postgresql.org (Postfix) with ESMTP id C40BED72F7 for ; Fri, 2 Sep 2005 08:43:07 -0300 (ADT) Received: from [127.0.0.1] ([192.168.10.56]) by mail.androme.com (8.12.10/8.12.10) with ESMTP id j82Bh5xx024069 for ; Fri, 2 Sep 2005 13:43:08 +0200 Message-ID: <43183AC9.1060704@andromeiberica.com> Date: Fri, 02 Sep 2005 13:43:05 +0200 From: Arnau Reply-To: arnaulist@andromeiberica.com User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Advise about how to delete entries Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/50 X-Sequence-Number: 14358 Hi all, I have the following table: espsm_asme=# \d statistics_sasme Table "public.statistics_sasme" Column | Type | Modifiers --------------------------+--------------------------+-------------------------------------------------------------- statistic_id | numeric(10,0) | not null default nextval('STATISTICS_OPERATOR_ID_SEQ'::text) input_message_id | character varying(50) | timestamp_in | timestamp with time zone | telecom_operator_id | numeric(4,0) | enduser_number | character varying(15) | not null telephone_number | character varying(15) | not null application_id | numeric(10,0) | customer_id | numeric(10,0) | customer_app_config_id | numeric(10,0) | customer_app_contents_id | numeric(10,0) | message | character varying(160) | message_type_id | numeric(4,0) | Indexes: "pk_stsasme_statistic_id" primary key, btree (statistic_id) Triggers: "RI_ConstraintTrigger_17328735" AFTER INSERT OR UPDATE ON statistics_sasme FROM telecom_operators NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins"('fk_stsasme_telecom_operator_id', 'statistics_sasme', 'telecom_operators', 'UNSPECIFIED', 'telecom_operator_id', 'telecom_operator_id') "RI_ConstraintTrigger_17328738" AFTER INSERT OR UPDATE ON statistics_sasme FROM applications NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins"('fk_stsasme_application_id', 'statistics_sasme', 'applications', 'UNSPECIFIED', 'application_id', 'application_id') "RI_ConstraintTrigger_17328741" AFTER INSERT OR UPDATE ON statistics_sasme FROM customers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins"('fk_stsasme_customer_id', 'statistics_sasme', 'customers', 'UNSPECIFIED', 'customer_id', 'customer_id') 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? Thank you very much