aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-05-12 18:30:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-05-12 18:30:17 -0400
commit8085a4f7510191b8fe7f8f7b5846fdbc79abcf8d (patch)
tree99525de1d41451aa7b492e4b19c1f95d00f2f2f1
parent5e2af609e14ede1b5e0d73d59ed8548c76e1943a (diff)
downloadpostgresql-8085a4f7510191b8fe7f8f7b5846fdbc79abcf8d.tar.gz
postgresql-8085a4f7510191b8fe7f8f7b5846fdbc79abcf8d.zip
Reduce initial size of RelfilenodeMapHash.
A test case provided by Mathieu Fenniak shows that hash_seq_search'ing this hashtable can consume a very significant amount of overhead during logical decoding, which triggers frequent cache invalidation. Testing suggests that the actual population of the hashtable is often no more than a few dozen entries, so we can cut the overhead just by dropping the initial number of buckets down from 1024 --- I chose to cut it to 64. (In situations where we do have a significant number of entries, we shouldn't get any real penalty from doing this, as the dynahash.c code will resize the hashtable automatically.) This gives a further factor-of-two savings in Mathieu's test case. That may be overly optimistic for real-world benefit, as real cases may have larger average table populations, but it's hard to see it turning into a net negative for any workload. Back-patch to 9.4 where relfilenodemap.c was introduced. Discussion: https://postgr.es/m/CAHoiPjzea6N0zuCi=+f9v_j94nfsy6y8SU7-=bp4=7qw6_i=Rg@mail.gmail.com
-rw-r--r--src/backend/utils/cache/relfilenodemap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index c790309caae..612f0f3a0d1 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -123,7 +123,7 @@ InitializeRelfilenodeMap(void)
* error.
*/
RelfilenodeMapHash =
- hash_create("RelfilenodeMap cache", 1024, &ctl,
+ hash_create("RelfilenodeMap cache", 64, &ctl,
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
/* Watch for invalidation events. */