Commit 6c450a8
committed
Cache the results of format_type() queries in pg_dump.
There's long been a "TODO: there might be some value in caching
the results" annotation on pg_dump's getFormattedTypeName function;
but we hadn't gotten around to checking what it was costing us to
repetitively look up type names. It turns out that when dumping the
current regression database, about 10% of the total number of queries
issued are duplicative format_type() queries. However, Hubert Depesz
Lubaczewski reported a not-unusual case where these account for over
half of the queries issued by pg_dump. Individually these queries
aren't expensive, but when network lag is a factor, they add up to a
problem. We can very easily add some caching to getFormattedTypeName
to solve it.
Since this is such a simple fix and can have a visible performance
benefit, back-patch to all supported branches.
Discussion: https://postgr.es/m/20210826084430.GA26282@depesz.com1 parent 628bc9d commit 6c450a8
2 files changed
+15
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5232 | 5232 | | |
5233 | 5233 | | |
5234 | 5234 | | |
| 5235 | + | |
5235 | 5236 | | |
5236 | 5237 | | |
5237 | 5238 | | |
| |||
18892 | 18893 | | |
18893 | 18894 | | |
18894 | 18895 | | |
18895 | | - | |
18896 | | - | |
18897 | 18896 | | |
18898 | 18897 | | |
18899 | 18898 | | |
18900 | 18899 | | |
| 18900 | + | |
18901 | 18901 | | |
18902 | 18902 | | |
18903 | 18903 | | |
| |||
18910 | 18910 | | |
18911 | 18911 | | |
18912 | 18912 | | |
| 18913 | + | |
| 18914 | + | |
| 18915 | + | |
| 18916 | + | |
| 18917 | + | |
18913 | 18918 | | |
18914 | 18919 | | |
18915 | 18920 | | |
| |||
18922 | 18927 | | |
18923 | 18928 | | |
18924 | 18929 | | |
| 18930 | + | |
| 18931 | + | |
| 18932 | + | |
| 18933 | + | |
18925 | 18934 | | |
18926 | 18935 | | |
18927 | 18936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
171 | 172 | | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
0 commit comments