Re: Separate memory contexts for relcache and catcache

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Separate memory contexts for relcache and catcache
Date: 2023-08-09 12:21:33
Message-ID: CAKU4AWrjsTp_BxG4WDYjTwY95syq7dfOKP2NpHRVSeFcEKPDbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Most catcache and relcache entries (other than index info etc.) currently
> go straight into CacheMemoryContext. And I believe these two caches can be
> the ones with the largest contribution to the memory usage of
> CacheMemoryContext most of the time. For example, in cases where we have
> lots of database objects accessed in a long-lived connection,
> CacheMemoryContext tends to increase significantly.
>
> While I've been working on another patch for pg_backend_memory_contexts
> view, we thought that it would also be better to see the memory usages of
> different kinds of caches broken down into their own contexts. The attached
> patch implements this and aims to easily keep track of the memory used by
> relcache and catcache
>
>
+ 1 for the idea, this would be pretty useful as a proof of which
context is consuming most of the memory and it doesn't cost
much. It would be handy than estimating that by something
like select count(*) from pg_class.

I think, for example, if we find relcache using too much memory,
it is a signal that the user may use too many partitioned tables.

--
Best Regards
Andy Fan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-08-09 12:48:27 Re: initial pruning in parallel append
Previous Message Melih Mutlu 2023-08-09 12:02:31 Separate memory contexts for relcache and catcache