From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Jan Wieck <jan@wi3ck.info>
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 13:43:10 -0400
Message-ID: <14681.1443202990@sss.pgh.pa.us> (raw)
In-Reply-To: <20150925173254.GK295765@alvherre.pgsql>
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>
<20150925173254.GK295765@alvherre.pgsql>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Would it make sense to remove the only the few oldest entries, instead
> of all of them? As is, I think this causes a storm of reloads every
> once in a while, if the number of FKs in the system is large enough.
> Maybe on a cache hit we could push the entry to the head of the list,
> and then remove N entries from the back of the list when the threshold
> is reached.
Sure, there's room for optimization of that sort, although I think we
could do with some evidence that it's actually helpful. I believe that
under "production" workloads InvalidateConstraintCacheCallBack won't
get called much at all, so the problem's moot.
(FWIW, it might take less code to put the recently-used entries at the
back of the list. Then the loop in InvalidateConstraintCacheCallBack
could just invalidate/delete entries if either they're targets, or
the current list length exceeds the threshold.)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, jan@wi3ck.info, kgrittn@postgresql.org, pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Fix an O(N^2) problem in foreign key references.
In-Reply-To: <14681.1443202990@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> <20150925173254.GK295765@alvherre.pgsql> <14681.1443202990@sss.pgh.pa.us>
* 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