Re: Advise about how to delete entries

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Arnau <arnaulist(at)andromeiberica(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Advise about how to delete entries
Date: 2005-09-02 13:36:10
Message-ID: 20050902133610.GB65294@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2005-09-02 14:40:54 Re: ORDER BY and LIMIT not propagated on inherited
Previous Message Matteo Beccati 2005-09-02 12:54:39 Re: ORDER BY and LIMIT not propagated on inherited