Advise about how to delete entries - Mailing list pgsql-performance

From Arnau
Subject Advise about how to delete entries
Date
Msg-id 43183AC9.1060704@andromeiberica.com
Whole thread Raw
Responses Re: Advise about how to delete entries
Re: Advise about how to delete entries
List 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


pgsql-performance by date:

Previous
From: Alex Stapleton
Date:
Subject: Re: Avoid using swap in a cluster
Next
From: Simon Riggs
Date:
Subject: Re: ORDER BY and LIMIT not propagated on inherited