pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Stanier <alexander.stanier@egsgroup.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to increase row deletion efficiency?
Date: Thu, 22 Dec 2005 17:13:51 +0000
Message-ID: <43AADECF.8070702@egsgroup.com> (raw)
In-Reply-To: <29270.1133968316@sss.pgh.pa.us>
References: <4396F360.6080000@egsgroup.com>
	<29270.1133968316@sss.pgh.pa.us>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Have only just had a chance to try this. There were several missing
indexes on the referencing columns including one on a table of circa
150K records. It now completes in a couple of minutes. Also it appears
to be quicker if one doesn't defer the constraints. Thanks for the
advice.<br>
<br>
Regards, Alex.<br>
<br>
Tom Lane wrote:
<blockquote cite="mid29270.1133968316@sss.pgh.pa.us" type="cite">
  <pre wrap="">Alexander Stanier <a class="moz-txt-link-rfc2396E" href="mailto:alexander.stanier@egsgroup.com">&lt;alexander.stanier@egsgroup.com&gt;</a> writes:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I am currently trying to separate two environments contained in one 
database. Essentially I need to break that one database down into two 
with a portion of the data going to each new database. I am intending to 
achieve this by duplicating the database and then stripping out the data 
that is not required in each database. I have started by trying to 
delete data from a set of 28 related tables, however the performance 
appears to be terrible. I am deleting from a table called document which 
cascades down to 27 tables underneath it linked by various cascading 
foreign key constraints. Some of these subsidiary tables have as many as 
a couple of million records.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Do you have indexes on the referencing columns?  PG enforces an index on
the referenced column, but not on the other end, and DELETE is where it
will hurt if you haven't got one.

			regards, tom lane

  </pre>
</blockquote>
</body>
</html>



view thread (3+ messages)

Message-ID: <43AADECF.8070702@egsgroup.com>
Permalink:  ../43AADECF.8070702@egsgroup.com/
Also on:    postgresql.org/message-id/43AADECF.8070702@egsgroup.com

 · 

reply

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-sql@postgresql.org
  Cc: alexander.stanier@egsgroup.com, tgl@sss.pgh.pa.us
  Subject: Re: How to increase row deletion efficiency?
  In-Reply-To: <43AADECF.8070702@egsgroup.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