postgresql/src/backend
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
..
access Compute XID horizon for page level index vacuum on primary. 2019-03-26 16:52:54 -07:00
bootstrap tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
catalog Fix partitioned index creation bug with dropped columns 2019-03-26 20:19:28 -03:00
commands Fix partitioned index creation bug with dropped columns 2019-03-26 20:19:28 -03:00
executor tableam: Add table_get_latest_tid, to wrap heap_get_latest_tid. 2019-03-25 17:14:48 -07:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Renaming for new subscripting mechanism 2019-02-01 12:50:32 -03:00
lib Further code review for new integerset code. 2019-03-25 12:23:48 -04:00
libpq Add DNS SRV support for LDAP server discovery. 2019-03-21 15:28:17 +13:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Fix use of wrong datatype with sizeof(). 2019-03-25 11:28:06 -04:00
optimizer Build "other rels" of appendrel baserels in a separate step. 2019-03-26 18:21:10 -04:00
parser Fix crash when using partition bound expressions 2019-03-26 10:09:14 +09:00
partitioning Fix misplaced const 2019-03-26 09:23:08 +01:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Add shared_memory_type GUC. 2019-02-03 12:47:26 +01:00
postmaster Add macro to cast away volatile without allowing changes to underlying type 2019-03-25 09:37:03 +01:00
regex Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
replication Add walreceiver API to get remote server version 2019-03-15 10:16:26 +01:00
rewrite tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Rename nodes/relation.h to nodes/pathnodes.h. 2019-01-29 16:49:25 -05:00
storage Track unowned relations in doubly-linked list 2019-03-27 02:39:39 +01:00
tcop Transaction chaining 2019-03-24 11:33:02 +01:00
tsearch Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
utils Fix misplaced const 2019-03-26 09:23:08 +01:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00