Question

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.

Was it helpful?

Solution

Is catalog and relation cache kept in shared memory or in session memory?

Both.

All relations in PostgreSQL are cached in shared memory up to the limit configured by shared_buffers parameter. This includes also system catalog (pg_class, pg_attribute, etc).

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 pg_buffercache.

Also, if we speak about caching you can't ignore the O/S filesystem caching machinery. See this excellent presentation.


OTHER TIPS

Those caches are per connection. They are not held in shared memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top