pgsql: Fix O(N^2) behavior in pg_dump when many objects are in dependen - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix O(N^2) behavior in pg_dump when many objects are in dependen
Date
Msg-id E1SE4L7-0001sC-Av@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix O(N^2) behavior in pg_dump when many objects are in dependency loops.

Combining the loop workspace with the record of already-processed objects
might have been a cute trick, but it behaves horridly if there are many
dependency loops to repair: the time spent in the first step of findLoop()
grows as O(N^2).  Instead use a separate flag array indexed by dump ID,
which we can check in constant time.  The length of the workspace array
is now never more than the actual length of a dependency chain, which
should be reasonably short in all cases of practical interest.  The code
is noticeably easier to understand this way, too.

Per gripe from Mike Roest.  Since this is a longstanding performance bug,
backpatch to all supported versions.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b1be1294cc3b3fbccc05294b3f67180f53d63ef3

Modified Files
--------------
src/bin/pg_dump/pg_dump_sort.c |  119 ++++++++++++++++++++--------------------
1 files changed, 59 insertions(+), 60 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix O(N^2) behavior in pg_dump when many objects are in dependen
Next
From: Tom Lane
Date:
Subject: pgsql: Fix O(N^2) behavior in pg_dump when many objects are in dependen