From: Richard Huxton <dev@archonet.com>
To: Volkan YAZICI <yazicivo@ttmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Unexpectedly Long DELETE Wait
Date: Thu, 07 Aug 2008 08:58:00 +0100
Message-ID: <489AAB08.9080409@archonet.com> (raw)
In-Reply-To: <874p5xwe3g.fsf@alamut.mobiliz.com.tr>
References: <874p5xwe3g.fsf@alamut.mobiliz.com.tr>
Volkan YAZICI wrote:
> Hi,
>
> Below command has been running since ~700 minutes in one of our
> PostgreSQL servers.
>
> DELETE FROM mugpsreglog
> WHERE NOT EXISTS (SELECT 1
> FROM mueventlog
> WHERE mueventlog.eventlogid = mugpsreglog.eventlogid);
>
> Seq Scan on mugpsreglog (cost=0.00..57184031821394.73 rows=6590986 width=6)
> Filter: (NOT (subplan))
> SubPlan
> -> Seq Scan on mueventlog (cost=0.00..4338048.00 rows=1 width=0)
> Filter: (eventlogid = $0)
Ouch - look at the estimated cost on that!
> And there isn't any constraints (FK/PK), triggers, indexes, etc. on any
> of the tables. (We're in the phase of a migration, many DELETE commands
> similar to above gets executed to relax constraints will be introduced.)
Well there you go. Add an index on eventlogid for mugpsreglog.
Alternatively, if you increased your work_mem that might help. Try SET
work_mem='64MB' (or even higher) before running the explain and see if
it tries a materialize. For situations like this where you're doing big
one-off queries you can afford to increase resource limits.
--
Richard Huxton
Archonet Ltd
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: dev@archonet.com, yazicivo@ttmail.com
Subject: Re: Unexpectedly Long DELETE Wait
In-Reply-To: <489AAB08.9080409@archonet.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