Skip site navigation (1) Skip section navigation (2)

Re: Delete query takes exorbitant amount of time

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Karim Nassar <Karim(dot)Nassar(at)acm(dot)org>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Delete query takes exorbitant amount of time
Date: 2005-03-25 00:52:07
Message-ID: 2630.1111711927@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Karim Nassar <Karim(dot)Nassar(at)acm(dot)org> writes:
> Here is the statement:

> orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE
> id_meas_type IN (SELECT * FROM meas_type_ids);
>                                                          QUERY PLAN 
> -----------------------------------------------------------------------------------------------------------------------------
>  Hash Join  (cost=11.53..42.06 rows=200 width=6) (actual
> time=1.564..2.840 rows=552 loops=1)
> ...
>  Total runtime: 2499616.216 ms
> (7 rows)

Notice that the actual join is taking 2.8 ms.  The other ~40 minutes is
in operations that we cannot see in this plan, but we can surmise are ON
DELETE triggers.

> Where do I go from here?

Look at what your triggers are doing.  My private bet is that you have
unindexed foreign keys referencing this table, and so each deletion
forces a seqscan of some other, evidently very large, table(s).

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Mark LewisDate: 2005-03-25 01:23:19
Subject: Re: Delete query takes exorbitant amount of time
Previous:From: Karim NassarDate: 2005-03-25 00:10:57
Subject: Delete query takes exorbitant amount of time

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group