Re: Very slow delete. - Mailing list pgsql-general

From Tom Lane
Subject Re: Very slow delete.
Date
Msg-id 27523.1097552329@sss.pgh.pa.us
Whole thread Raw
In response to Very slow delete.  (Brock Henry <brock.henry@gmail.com>)
Responses Re: Very slow delete.  (Brock Henry <brock.henry@gmail.com>)
List pgsql-general
Brock Henry <brock.henry@gmail.com> writes:
> delete from people where id < '2000'

> Index Scan using people_pkey on people  (cost=0.00..71.68 rows=2792
> width=6) (actual time=1.361..5.657 rows=2000 loops=1)
>   Index Cond: (id < 3000)
> Total runtime: 13.006 ms
> 3 row(s)
> Total runtime: 63,869.322 ms

So 13 msec to find the rows to delete, and 63850+ msec in overhead.
Which is certainly from the foreign keys that reference this table,
because the referencing tables have to be checked to see if they
contain copies of the key values being deleted.

You either don't have indexes on the referencing columns, or there
is a datatype mismatch, or possibly you need to update statistics
for those tables.

            regards, tom lane

pgsql-general by date:

Previous
From: Brock Henry
Date:
Subject: Very slow delete.
Next
From: Michael Fuhr
Date:
Subject: Re: Reiniciar secuencias