Re: Get rid of redundant StringInfo accumulation - Mailing list pgsql-hackers

From Peter Smith
Subject Re: Get rid of redundant StringInfo accumulation
Date
Msg-id CAHut+PvX8s0KBFeKOq+O1T+R0pdBGOp445QK1p6nVScnxSLFaA@mail.gmail.com
Whole thread Raw
In response to Get rid of redundant StringInfo accumulation  (Daniil Davydov <3danissimo@gmail.com>)
Responses Re: Get rid of redundant StringInfo accumulation
List pgsql-hackers
On Sun, Mar 29, 2026 at 11:26 PM Daniil Davydov <3danissimo@gmail.com> wrote:
>
> Hi,
>
> I have noticed that there are several places in the code where we are
> creating StringInfo in order to log its content. But this work may be wasted
> if the specified log level is not interesting both for client and server.
> I.e. now we can allocate memory for StringInfo which will never be displayed.
>
> I think that at first we should check whether log level is interesting and
> only then start creating the StringInfo.
>
> Please, see the attached patch that fixes it. I hope I have found all the
> places where it would be appropriate.
>

Hi,

1.
@@ -108,6 +108,9 @@ ReportApplyConflict(EState *estate, ResultRelInfo
*relinfo, int elevel,
  Relation localrel = relinfo->ri_RelationDesc;
  StringInfoData err_detail;

+ if (!message_level_is_interesting(elevel))
+ return;
+

AFAICT, this change will also cause the
pgstat_report_subscription_conflict() to be skipped. But that call was
not associated with the log level.

======
Kind Regards,
Peter Smith.
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Patch: dumping tables data in multiple chunks in pg_dump
Next
From: Alvaro Herrera
Date:
Subject: Re: Adding REPACK [concurrently]