Avoid building stderr message if possible

From: cca5507 <cca5507(at)qq(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Avoid building stderr message if possible
Date: 2026-08-02 15:51:28
Message-ID: tencent_A00A556AC153E46588F0680E34ED4C43EF09@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Now we always build a message formatted for stderr in send_message_to_server_log()
even if it's useless in some case, e.g., log_destination = 'csvlog'. Attach a patch to
avoid building it if possible.

Test
====
I test it with a large sql (32MB) with guc:
```
log_destination = 'csvlog'
logging_collector = on
log_min_duration_statement = 0
```

master:
```
pgbench (20devel)
transaction type: large.sql
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 205
number of failed transactions: 0 (0.000%)
latency average = 293.219 ms
initial connection time = 0.767 ms
tps = 3.410415 (without initial connection time)
```

patched:
```
pgbench (20devel)
transaction type: large.sql
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 229
number of failed transactions: 0 (0.000%)
latency average = 263.087 ms
initial connection time = 1.068 ms
tps = 3.801022 (without initial connection time)
```

Thoughts?

--
Regards,
ChangAo Chen

Attachment Content-Type Size
v1-0001-Avoid-building-stderr-message-if-possible.patch application/octet-stream 6.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-08-02 16:00:00 Re: walsummarizer can get stuck when switching timelines
Previous Message Alexander Korotkov 2026-08-02 15:30:04 Re: GiST multirange index scans can fail to return rows