pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <jan@wi3ck.info>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kevin Grittner <kgrittn@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Fix an O(N^2) problem in foreign key references.
Date: Fri, 25 Sep 2015 10:20:30 -0400
Message-ID: <5605582E.1010209@wi3ck.info> (raw)
In-Reply-To: <16320.1442587639@sss.pgh.pa.us>
References: <E1ZaSzE-0007q3-2V@gemulon.postgresql.org>
	<10758.1442239007@sss.pgh.pa.us>
	<55F81C48.4020009@wi3ck.info>
	<22834.1442325108@sss.pgh.pa.us>
	<1935.1442329129@sss.pgh.pa.us>
	<55F83ABF.2080609@wi3ck.info>
	<4716.1442332474@sss.pgh.pa.us>
	<55F84112.8020307@wi3ck.info>
	<55FB7089.1030702@wi3ck.info>
	<16320.1442587639@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 09/18/2015 10:47 AM, Tom Lane wrote:
> Jan Wieck <jan@wi3ck.info> writes:
>> Attached is a complete rework of the fix from scratch, based on Tom's
>> suggestion.
>
>> The code now maintains a double linked list as suggested, but only uses
>> it to mark all currently valid entries as invalid when hashvalue == 0.
>> If a specific entry is invalidated it performs a hash lookup for maximum
>> efficiency in that case.
>
> That does not work; you're ignoring the possibility of hashvalue
> collisions, and for that matter not considering that the hash value
> is not equal to the hash key.  I don't think your code is invalidating
> the right entry at all during a foreign key constraint update, and
> it certainly cannot do the right thing if there's a hash value collision.
>
> Attached is something closer to what I was envisioning; can you do
> performance testing on it?

Sorry for the delay.

Yes, that patch also has the desired performance for restoring a schema 
with hundreds of thousands of foreign key constraints.


Regards, Jan

-- 
Jan Wieck
Senior Software Engineer
http://slony.info


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (19+ messages)  latest in thread

Message-ID: <5605582E.1010209@wi3ck.info>
Permalink:  ../5605582E.1010209@wi3ck.info/
Also on:    postgresql.org/message-id/5605582E.1010209@wi3ck.info

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: jan@wi3ck.info, tgl@sss.pgh.pa.us, kgrittn@postgresql.org, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Fix an O(N^2) problem in foreign key references.
  In-Reply-To: <5605582E.1010209@wi3ck.info>
  References: <E1ZaSzE-0007q3-2V@gemulon.postgresql.org> <10758.1442239007@sss.pgh.pa.us> <55F81C48.4020009@wi3ck.info> <22834.1442325108@sss.pgh.pa.us> <1935.1442329129@sss.pgh.pa.us> <55F83ABF.2080609@wi3ck.info> <4716.1442332474@sss.pgh.pa.us> <55F84112.8020307@wi3ck.info> <55FB7089.1030702@wi3ck.info> <16320.1442587639@sss.pgh.pa.us> <5605582E.1010209@wi3ck.info>

* 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