Re: [PERFORM] Foreign key performance

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Brown <kevin(at)sysexperts(dot)com>, <pgsql-hackers(at)postgresql(dot)org>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [PERFORM] Foreign key performance
Date: 2003-04-18 06:25:20
Message-ID: 20030417231421.O97534-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On Fri, 18 Apr 2003, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> > It appears (from some not terribly scientific experiments - see below)
> > that it's likely to be related to managing the deferred trigger queue
> > given that in my case at least running the constraints non-deferred was
> > negligible in comparison.
>
> At one time the deferred-trigger queue had an O(N^2) behavioral problem
> for large N = number of pending trigger events. But I thought we'd
> fixed that. What's the test case exactly? Can you get a profile with
> gprof?

I'm going to tomorrow hopefully - but it looks to me that we fixed one, but
possibly not another place where we read through the list unnecessarily
AFAICS. I think deferredTriggerInvokeEvents (when called with
immediate_only = true) is going to go through the entire list looking for
immediate triggers to fire after each statement. However, excepting set
constraints, any immediate triggers for any event added prior to this
statement will by necessity have already been run unless I'm missing
something, which means that we're often looking through entries that
aren't going to have any triggers to run now in any case.

Keeping a pointer to the end of the list as of last statement and going
through the list from there cut the time for the deferred case in half in
my simple test (about 3.3x the no fk and just under 2x the immediate).

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas O'Dowd 2003-04-18 06:39:08 Re: pg 7.3.2 assert statement fails. process terminated
Previous Message Kevin Brown 2003-04-18 06:19:57 Re: For the ametures. (related to "Are we losing momentum?")

Browse pgsql-performance by date

  From Date Subject
Next Message Stephan Szabo 2003-04-18 14:47:15 Re: [PERFORM] Foreign key performance
Previous Message Tom Lane 2003-04-18 06:06:04 Re: [PERFORM] Foreign key performance