From: Mark Lewis <mark.lewis@mir3.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: Delete query takes exorbitant amount of time
Date: Thu, 24 Mar 2005 17:23:19 -0800
Message-ID: <1111713798.23412.3.camel@amateljan.mirlogic.com> (raw)
In-Reply-To: <2630.1111711927@sss.pgh.pa.us>
References: <1111709457.9085.127.camel@k2.cet.nau.edu>
<2630.1111711927@sss.pgh.pa.us>
Tom,
I've got a similar problem with deletes taking a very long time. I know
that there are lots of foreign keys referencing this table, and other
foreign keys referencing those tables, etc. I've been curious, is there
a way to find out how long the foreign key checks take for each
dependent table?
-- Mark Lewis
On Thu, 2005-03-24 at 16:52, Tom Lane wrote:
> Karim Nassar <Karim.Nassar@acm.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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mark.lewis@mir3.com, tgl@sss.pgh.pa.us
Subject: Re: Delete query takes exorbitant amount of time
In-Reply-To: <1111713798.23412.3.camel@amateljan.mirlogic.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox