Get rid of redundant StringInfo accumulation

From: Daniil Davydov <3danissimo(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Get rid of redundant StringInfo accumulation
Date: 2026-03-29 12:26:11
Message-ID: CAJDiXgi=Vcp1nh2UoZ5=7BCoR+uXoYzqMsfOfga-XxSUHjFj5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

--
Best regards,
Daniil Davydov

Attachment Content-Type Size
v1-0001-Get-rid-of-redundant-calculations.patch text/x-patch 3.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2026-03-29 12:34:06 Re: Exit walsender before confirming remote flush in logical replication
Previous Message Tomas Vondra 2026-03-29 12:16:47 Re: Compress prune/freeze records with Delta Frame of Reference algorithm