Re: [SQL] 7.4 - FK constraint performance

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] 7.4 - FK constraint performance
Date: 2004-02-18 16:03:36
Message-ID: 20040218075937.T23729@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Sun, 15 Feb 2004, Stephan Szabo wrote:

> On Fri, 13 Feb 2004, Stephan Szabo wrote:
>
> >
> > On Fri, 13 Feb 2004, Tom Lane wrote:
> >
> > > Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> > > > On Fri, 13 Feb 2004, Tom Lane wrote:
> > > >> I was looking at that last night. It seems like we could add a LIMIT at
> > > >> least in some contexts. In the case at hand, we're just going to error
> > > >> out immediately if we find a matching row, and so there's no need for
> > > >> FOR UPDATE, is there?
> > >
> > > > I think there still is, because a not yet committed transaction could have
> > > > deleted them all in which case I think the correct behavior is to wait and
> > > > if that transaction commits allow the action and if it rolls back to
> > > > error.
> > >
> > > Good point. Okay, we can't put in a LIMIT. But we could still hack the
> > > planner to prefer a fast-start plan by passing an out-of-band tuple
> > > fraction, for those RI plans where it's appropriate. That would not
> > > affect correctness.
> >
> > Right, I can try to look through the stuff you pointed at in the previous
> > message over the weekend.
>
> It looks to me that we could make this available to SPI fairly simply by
> taking the current version of the following four routines: planner,
> pg_plan_query, _SPI_execute and SPI_prepare, renaming them and giving them
> a planning tuple fraction as a parameter, change references to the other
> routines to the new names and then making four new functions with the
> current names that call the renamed versions. In all the cases other than
> planner I think we can have the new version pass 0.0 and in the case of
> planner either 0.1 or 0.0 based on the isCursor parameter.

I did this, and changed the foreign keys to use it, but I haven't managed
to build a fk case where I could actually detect a change in the plan
chosen. Since the queries are only a simple scan on the one table I'm
wondering if it's basically just modifying both costs by the same value
which means there's no real effect at all.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brett Schwarz 2004-02-18 16:14:15 Re: OIDs, CTIDs, updateable cursors and friends
Previous Message Tom Lane 2004-02-18 15:56:00 Re: CHAR(n) always trims trailing spaces in 7.4

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2004-02-18 16:08:22 Re: bytea or blobs?
Previous Message Tom Lane 2004-02-18 15:56:00 Re: CHAR(n) always trims trailing spaces in 7.4