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

Re: Delete query takes exorbitant amount of time

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>,Karim A Nassar <Karim(dot)Nassar(at)NAU(dot)EDU>,Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>,pgsql-performance(at)postgresql(dot)org
Subject: Re: Delete query takes exorbitant amount of time
Date: 2005-03-29 16:33:20
Message-ID: 20050329083027.I58020@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Tue, 29 Mar 2005, Simon Riggs wrote:

> On Tue, 2005-03-29 at 10:31 -0500, Tom Lane wrote:
> > Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > > If action is NO ACTION or RESTRICT then
> > > 	we need to SELECT at most 1 row that matches the criteria
> > > 	which means we can use LIMIT 1
> >
> > > If action is CASCADE, SET NULL, SET DEFAULT then
> > > 	we need to UPDATE or DELETE all rows that match the criteria
> > > 	which means we musnt use LIMIT and need to use FOR UPDATE
> >
> > Huh?  UPDATE/DELETE don't use FOR UPDATE.  I think you have failed
> > to break down the cases sufficiently.  In particular it matters which
> > side of the RI constraint you are working from ...
>
> OK... too quick, sorry. I'll hand over to Stephan for a better and more
> exhaustive explanation/analysis... but AFAICS we *can* always know the
> correct formulation of the query prepare time, whether or not we do
> currently.

We currently use FOR UPDATE on the NO ACTION check, because otherwise we
might get back a row that's already marked for deletion by a concurrent
transaction.  I think that's intended to wait and succeed, not fail.


In response to

pgsql-performance by date

Next:From: Stephan SzaboDate: 2005-03-29 16:38:28
Subject: Re: Delete query takes exorbitant amount of time
Previous:From: Simon RiggsDate: 2005-03-29 16:01:27
Subject: Re: Delete query takes exorbitant amount of time

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