Commit 96198d9
committed
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.1 parent 80db1ca commit 96198d9
File tree
5 files changed
+26
-34
lines changed- contrib/postgres_fdw
- src
- backend/foreign
- include/foreign
5 files changed
+26
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | | - | |
98 | | - | |
| 95 | + | |
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
| |||
127 | 124 | | |
128 | 125 | | |
129 | 126 | | |
130 | | - | |
131 | | - | |
| 127 | + | |
132 | 128 | | |
133 | 129 | | |
134 | 130 | | |
| |||
156 | 152 | | |
157 | 153 | | |
158 | 154 | | |
| 155 | + | |
| 156 | + | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
162 | 160 | | |
163 | | - | |
164 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
165 | 164 | | |
166 | 165 | | |
167 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1101 | 1101 | | |
1102 | 1102 | | |
1103 | 1103 | | |
1104 | | - | |
1105 | 1104 | | |
1106 | 1105 | | |
1107 | 1106 | | |
| |||
1129 | 1128 | | |
1130 | 1129 | | |
1131 | 1130 | | |
1132 | | - | |
1133 | | - | |
| 1131 | + | |
1134 | 1132 | | |
1135 | 1133 | | |
1136 | 1134 | | |
1137 | 1135 | | |
1138 | 1136 | | |
1139 | | - | |
| 1137 | + | |
1140 | 1138 | | |
1141 | 1139 | | |
1142 | 1140 | | |
| |||
1503 | 1501 | | |
1504 | 1502 | | |
1505 | 1503 | | |
1506 | | - | |
1507 | 1504 | | |
1508 | 1505 | | |
1509 | 1506 | | |
| |||
1530 | 1527 | | |
1531 | 1528 | | |
1532 | 1529 | | |
1533 | | - | |
1534 | | - | |
| 1530 | + | |
1535 | 1531 | | |
1536 | 1532 | | |
1537 | | - | |
| 1533 | + | |
1538 | 1534 | | |
1539 | 1535 | | |
1540 | 1536 | | |
| |||
1988 | 1984 | | |
1989 | 1985 | | |
1990 | 1986 | | |
1991 | | - | |
| 1987 | + | |
1992 | 1988 | | |
1993 | 1989 | | |
1994 | 1990 | | |
| |||
2544 | 2540 | | |
2545 | 2541 | | |
2546 | 2542 | | |
2547 | | - | |
2548 | 2543 | | |
2549 | 2544 | | |
2550 | 2545 | | |
| |||
2565 | 2560 | | |
2566 | 2561 | | |
2567 | 2562 | | |
2568 | | - | |
2569 | | - | |
2570 | | - | |
| 2563 | + | |
| 2564 | + | |
2571 | 2565 | | |
2572 | 2566 | | |
2573 | 2567 | | |
| |||
2626 | 2620 | | |
2627 | 2621 | | |
2628 | 2622 | | |
2629 | | - | |
2630 | 2623 | | |
2631 | 2624 | | |
2632 | 2625 | | |
| |||
2657 | 2650 | | |
2658 | 2651 | | |
2659 | 2652 | | |
2660 | | - | |
2661 | | - | |
2662 | | - | |
| 2653 | + | |
| 2654 | + | |
2663 | 2655 | | |
2664 | 2656 | | |
2665 | 2657 | | |
| |||
2860 | 2852 | | |
2861 | 2853 | | |
2862 | 2854 | | |
2863 | | - | |
| 2855 | + | |
2864 | 2856 | | |
2865 | 2857 | | |
2866 | 2858 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
0 commit comments