diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-01-28 12:05:19 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-01-28 12:05:19 -0500 |
commit | 96198d94cb7adc664bda341842dc8db671d8be72 (patch) | |
tree | c488bd043f0dd42d0340acd5eb029b38636a5d72 /src | |
parent | 80db1ca2d79338c35bb3e01f2aecad78c2231b06 (diff) |
Avoid multiple foreign server connections when all use same user mapping.
Previously, postgres_fdw's connection cache was keyed by user OID and
server OID, but this can lead to multiple connections when it's not
really necessary. In particular, if all relevant users are mapped to
the public user mapping, then their connection options are certainly
the same, so one connection can be used for all of them.
While we're cleaning things up here, drop the "server" argument to
GetConnection(), which isn't really needed. This saves a few cycles
because callers no longer have to look this up; the function itself
does, but only when establishing a new connection, not when reusing
an existing one.
Ashutosh Bapat, with a few small changes by me.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/foreign/foreign.c | 1 | ||||
-rw-r--r-- | src/include/foreign/foreign.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c index 14e082b5b8b..c24b11b685c 100644 --- a/src/backend/foreign/foreign.c +++ b/src/backend/foreign/foreign.c @@ -193,6 +193,7 @@ GetUserMapping(Oid userid, Oid serverid) MappingUserName(userid)))); um = (UserMapping *) palloc(sizeof(UserMapping)); + um->umid = HeapTupleGetOid(tp); um->userid = userid; um->serverid = serverid; diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h index 2c1ada1b12a..5dc2c90f3c3 100644 --- a/src/include/foreign/foreign.h +++ b/src/include/foreign/foreign.h @@ -55,6 +55,7 @@ typedef struct ForeignServer typedef struct UserMapping { + Oid umid; /* Oid of user mapping */ Oid userid; /* local user Oid */ Oid serverid; /* server Oid */ List *options; /* useoptions as DefElem list */ |