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
