Re: Delete query takes exorbitant amount of time - Mailing list pgsql-performance

From Simon Riggs
Subject Re: Delete query takes exorbitant amount of time
Date
Msg-id 1112109880.11750.977.camel@localhost.localdomain
Whole thread Raw
In response to Re: Delete query takes exorbitant amount of time  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Delete query takes exorbitant amount of time
List pgsql-performance
On Tue, 2005-03-29 at 09:56 -0500, Tom Lane wrote:
> Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> > If there were some way to pass a "limit" into SPI_prepare that was treated
> > similarly to a LIMIT clause for planning purposes but didn't actually
> > change the output plan to only return that number of rows, we could use
> > that.
>
> Hmm ... the planner does have the ability to do that sort of thing (we
> use it for cursors).  SPI_prepare doesn't expose the capability.
> Perhaps adding a SPI_prepare variant that does expose it would be the
> quickest route to a solution.
>
> I get a headache every time I look at the RI triggers ;-).  Do they
> always know at the time of preparing a plan which way it will be used?

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

We know that at CONSTRAINT creation time, which always occurs before
plan preparation time.

Best Regards, Simon Riggs


pgsql-performance by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Delete query takes exorbitant amount of time
Next
From: Tom Lane
Date:
Subject: Re: Delete query takes exorbitant amount of time