From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Track unowned relations in doubly-linked list
Date: Wed, 27 Mar 2019 02:30:18 +0000
Message-ID: <E1h8yKY-00015N-Jf@gemulon.postgresql.org> (raw)
Track unowned relations in doubly-linked list
Relations dropped in a single transaction are tracked in a list of
unowned relations. With large number of dropped relations this resulted
in poor performance at the end of a transaction, when the relations are
removed from the singly linked list one by one.
Commit b4166911 attempted to address this issue (particularly when it
happens during recovery) by removing the relations in a reverse order,
resulting in O(1) lookups in the list of unowned relations. This did
not work reliably, though, and it was possible to trigger the O(N^2)
behavior in various ways.
Instead of trying to remove the relations in a specific order with
respect to the linked list, which seems rather fragile, switch to a
regular doubly linked. That allows us to remove relations cheaply no
matter where in the list they are.
As b4166911 was a bugfix, backpatched to all supported versions, do the
same thing here.
Reviewed-by: Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/flat/80c27103-99e4-1d0c-642c-d9f3b94aaa0a%402ndquadrant.com
Backpatch-through: 9.4
Branch
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/5601f9fb97d108cb26ee92d0941447f354688421
Modified Files
--------------
src/backend/storage/smgr/md.c | 8 +----
src/backend/storage/smgr/smgr.c | 74 ++++++++++-------------------------------
src/include/storage/smgr.h | 3 +-
3 files changed, 20 insertions(+), 65 deletions(-)
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: tomas.vondra@postgresql.org
Subject: Re: pgsql: Track unowned relations in doubly-linked list
In-Reply-To: <E1h8yKY-00015N-Jf@gemulon.postgresql.org>
References: <E1h8yKY-00015N-Jf@gemulon.postgresql.org>
* 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