Re: Get rid of redundant StringInfo accumulation

From: Andres Freund <andres(at)anarazel(dot)de>
To: Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Get rid of redundant StringInfo accumulation
Date: 2026-03-30 12:52:17
Message-ID: eok6kgntbec2vo35xp4eky5ef52ttb7trislyev63ty3ltu533@je4bpifl6spb
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-03-29 19:26:11 +0700, Daniil Davydov wrote:
> 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.

I don't see when the overhead of creating an populating the string info ever
matters in these cases. This is optimizing something that never can matter for
real world performance. Even if it were worth optimizing them, I doubt that
the log level check is useful here, because most if not all of these are
logged with a level that's logged in nearly all installations.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2026-03-30 12:56:12 Re: Add pg_stat_autovacuum_priority
Previous Message Andres Freund 2026-03-30 12:39:23 Re: .bc files build dependency issues.