postgresql/src
Tomas Vondra 6ca015f9f0 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
2019-03-27 02:39:39 +01:00
..
backend Track unowned relations in doubly-linked list 2019-03-27 02:39:39 +01:00
bin psql: Schema-qualify typecast in one \d query 2019-03-26 13:06:41 -03:00
common Refactor more code logic to update the control file 2019-03-18 12:59:35 +09:00
fe_utils pgbench: Remove \cset 2019-03-25 12:16:07 -03:00
include Track unowned relations in doubly-linked list 2019-03-27 02:39:39 +01:00
interfaces Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
makefiles Move port-specific parts of with_temp_install to port makefile. 2019-02-04 18:54:56 +00:00
pl Transaction chaining 2019-03-24 11:33:02 +01:00
port Fix error handling of readdir() port implementation on first file lookup 2019-03-04 09:49:06 +09:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Fix partitioned index creation bug with dropped columns 2019-03-26 20:19:28 -03:00
timezone More unconstify use 2019-02-13 11:50:16 +01:00
tools Compute XID horizon for page level index vacuum on primary. 2019-03-26 16:52:54 -07:00
tutorial SQL comment: remove extra word in heading comment 2019-01-25 18:57:21 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Revert attempts to use POPCNT etc instructions 2019-02-15 16:32:30 -03:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00