Advise about how to delete entries

From: Arnau <arnaulist(at)andromeiberica(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Advise about how to delete entries
Date: 2005-09-02 11:43:05
Message-ID: 43183AC9.1060704@andromeiberica.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Simon Riggs 2005-09-02 12:35:32 Re: ORDER BY and LIMIT not propagated on inherited
Previous Message Alex Stapleton 2005-09-02 11:18:22 Re: Avoid using swap in a cluster