Commit 333b4a45 authored by Bruce Momjian's avatar Bruce Momjian

Cache most recent relfilenode lookups, for speed, after report of

pg_upgrade slowness for 150k tables.
parent ad06db26
...@@ -423,11 +423,21 @@ relarr_lookup_rel(RelInfoArr *rel_arr, ...@@ -423,11 +423,21 @@ relarr_lookup_rel(RelInfoArr *rel_arr,
const char *nspname, const char *relname, const char *nspname, const char *relname,
Cluster whichCluster) Cluster whichCluster)
{ {
int relnum; static int relnum = 0;
if (!rel_arr || !relname) if (!rel_arr || !relname)
return NULL; return NULL;
/* Test most recent lookup first, for speed */
if (strcmp(rel_arr->rels[relnum].nspname, nspname) == 0 &&
strcmp(rel_arr->rels[relnum].relname, relname) == 0)
return &rel_arr->rels[relnum];
if (relnum + 1 < rel_arr->nrels &&
strcmp(rel_arr->rels[relnum + 1].nspname, nspname) == 0 &&
strcmp(rel_arr->rels[relnum + 1].relname, relname) == 0)
return &rel_arr->rels[relnum + 1];
for (relnum = 0; relnum < rel_arr->nrels; relnum++) for (relnum = 0; relnum < rel_arr->nrels; relnum++)
{ {
if (strcmp(rel_arr->rels[relnum].nspname, nspname) == 0 && if (strcmp(rel_arr->rels[relnum].nspname, nspname) == 0 &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment