postgresql/src/backend/storage
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
..
buffer Update copyright for 2019 2019-01-02 12:44:25 -05:00
file Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
freespace Improve code comments in b0eaa4c51b. 2019-03-16 06:55:56 +05:30
ipc Add macro to cast away volatile without allowing changes to underlying type 2019-03-25 09:37:03 +01:00
large_object Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
lmgr Enable parallel query with SERIALIZABLE isolation. 2019-03-15 17:47:04 +13:00
page Track block level checksum failures in pg_stat_database 2019-03-09 10:47:30 -08:00
smgr Track unowned relations in doubly-linked list 2019-03-27 02:39:39 +01:00
Makefile Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00