pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Free memory after building each statistics object
Date: Thu, 23 Sep 2021 16:53:38 +0000
Message-ID: <E1mTRyc-0005FY-1y@gemulon.postgresql.org> (raw)

Free memory after building each statistics object

Until now, all extended statistics on a given relation were built in the
same memory context, without resetting. Some of the memory was released
explicitly, but not all of it - for example memory allocated while
detoasting values is hard to free. This is how it worked since extended
statistics were introduced in PostgreSQL 10, but adding support for
extended stats on expressions made the issue somewhat worse as it
increases the number of statistics to build.

Fixed by adding a memory context which gets reset after building each
statistics object (all the statistics kinds included in it). Resetting
it after building each statistics kind would be even better, but it
would require more invasive changes and copying of results, making it
harder to backpatch.

Backpatch to PostgreSQL 10, where extended statistics were introduced.

Author: Justin Pryzby
Reported-by: Justin Pryzby
Reviewed-by: Tomas Vondra
Backpatch-through: 10
Discussion: https://www.postgresql.org/message-id/20210915200928.GP831%40telsasoft.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ac7290a20ec52fa95316e30191827594b60470d3

Modified Files
--------------
src/backend/statistics/extended_stats.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1mTRyc-0005FY-1y@gemulon.postgresql.org>
Permalink:  ../E1mTRyc-0005FY-1y@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mTRyc-0005FY-1y@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Free memory after building each statistics object
  In-Reply-To: <E1mTRyc-0005FY-1y@gemulon.postgresql.org>
  References: <E1mTRyc-0005FY-1y@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox