From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jonatan Evald Buus <jonatan.buus@cellpointmobile.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Poor performance for delete query
Date: Thu, 24 Apr 2014 16:29:00 -0400
Message-ID: <28604.1398371340@sss.pgh.pa.us> (raw)
In-Reply-To: <CABnF-8Lyps8ribpp=BOFnqGEeWp2K5iuLukMo3txQ5UkgHjF7g@mail.gmail.com>
References: <CABnF-8Lyps8ribpp=BOFnqGEeWp2K5iuLukMo3txQ5UkgHjF7g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Jonatan Evald Buus <jonatan.buus@cellpointmobile.com> writes:
> We're currently having very poor performance for the following delete query.
> DELETE FROM TopTable WHERE id IN (xx, yy, zz);
> We've observed that it takes around 7 seconds under normal load to for each
> row that's being from TopTable and several minutes pr deleted row under
> heavy load.
I'd really have to bet that you forgot to index one of the referencing
tables. Are any of the foreign keys multi-column? If so you probably
need a matching multi-column index, not just indexes on the individual
referencing columns.
> How do we track down the cause of the poorly performing delete query?
EXPLAIN ANALYZE on a DELETE, for starters. That would isolate whether
it's the DELETE itself or one of the foreign-key updates, and if the
latter which one. It's a little bit difficult to see the exact plan being
used for a foreign-key update query, but I think one way you could do it
is to enable auto_explain with auto_explain.log_nested_statements turned
on.
regards, tom lane
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
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: tgl@sss.pgh.pa.us, jonatan.buus@cellpointmobile.com
Subject: Re: Poor performance for delete query
In-Reply-To: <28604.1398371340@sss.pgh.pa.us>
* 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