Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

md.c

Blame
    • Tomas Vondra's avatar
      31737eb4
      Track unowned relations in doubly-linked list · 31737eb4
      Tomas Vondra authored
      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
      31737eb4
      History
      Track unowned relations in doubly-linked list
      Tomas Vondra authored
      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