public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Chao Li <[email protected]>
Cc: Corey Huinker <[email protected]>
Cc: Postgres hackers <[email protected]>
Cc: Tomas Vondra <[email protected]>
Subject: Re: Defects with invalid stats data for expressions in extended stats
Date: Mon, 2 Mar 2026 09:20:37 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CADkLM=c_3mPHr0JGP_72csQkpAt-v2fRN830RO8or1_R1qX2Wg@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On Mon, Mar 02, 2026 at 07:39:45AM +0800, Chao Li wrote:
> But why do we still explicitly free the stats array? My concern is
> mostly about “partial free”: either free everything, or free nothing
> and let the memory context clean it up. “Partial free” tends to
> confuse code readers, and future readers may keep running into the
> same question. 

Not necessarity.  We have plenty of these patterns in the code with
such partial frees.  At the end, two things tend to take priority:
the readability of the code as well as its efficiency because repeated
pfree() calls can be more expensive than a memory context cleanup,
particularly in hot loops, though doing pfree() calls may be better in
some cases.

In this case, I see a better argument with the code clarity, as we use
the same array for the stats built with attributes and expressions.
We also cap the number of expressions to 8, which puts some control.
But at the end it does not really matter: in this context ANALYZE
makes sure that nothing crosses the processing of a single relation,
even with a transaction analyzes a lot of relations (same or
different).
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
  download

view thread (11+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Defects with invalid stats data for expressions in extended stats
  In-Reply-To: <[email protected]>

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

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