I am trying to figure out if Postgres' relation and catalog cache are per connection or per server? I did find that plan caches are per connection. It would make sense for the cache to exist for as long as the server is running, but I can't find any documentation on it.
Is catalog and relation cache kept in shared memory or in session memory?
All relations in PostgreSQL are cached in shared memory up to the limit configured by
shared_buffers parameter. This includes also system catalog (
When a session is running, it builds its own internal cache in private memory for many things - including query plans, name-oid mappings etc.
On query level you can review caching effect with EXPLAIN command - see this answer.
On global level you can inspect contents of shared buffers using a standard extension named
Also, if we speak about caching you can't ignore the O/S filesystem caching machinery. See this excellent presentation.