summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/common.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-03-31 14:42:28 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-03-31 14:42:28 -0400
commitb77da19930e6b6f0e8ff0f721e59713e3709eea1 (patch)
tree74bbf590f0b1ada19bc138eddd59e43740660c6d /src/bin/pg_dump/common.c
parent6205bb6e2875514c191370f22f1e10184b655fc5 (diff)
Fix O(N^2) behavior in pg_dump for large numbers of owned sequences.
The loop that matched owned sequences to their owning tables required time proportional to number of owned sequences times number of tables; although this work was only expended in selective-dump situations, which is probably why the issue wasn't recognized long since. Refactor slightly so that we can perform this work after the index array for findTableByOid has been set up, reducing the time to O(M log N). Per gripe from Mike Roest. Since this is a longstanding performance bug, backpatch to all supported versions.
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r--src/bin/pg_dump/common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index aae1e481eb6..48a97392e14 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -126,6 +126,9 @@ getSchemaData(int *numTablesPtr)
tblinfo = getTables(&numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
+ /* Do this after we've built tblinfoindex */
+ getOwnedSeqs(tblinfo, numTables);
+
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
funinfo = getFuncs(&numFuncs);