]> granicus.if.org Git - postgresql/commit
Avoid multiple foreign server connections when all use same user mapping.
authorRobert Haas <rhaas@postgresql.org>
Thu, 28 Jan 2016 17:05:19 +0000 (12:05 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 28 Jan 2016 17:05:19 +0000 (12:05 -0500)
commit96198d94cb7adc664bda341842dc8db671d8be72
treec488bd043f0dd42d0340acd5eb029b38636a5d72
parent80db1ca2d79338c35bb3e01f2aecad78c2231b06
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.
contrib/postgres_fdw/connection.c
contrib/postgres_fdw/postgres_fdw.c
contrib/postgres_fdw/postgres_fdw.h
src/backend/foreign/foreign.c
src/include/foreign/foreign.h