Re: Make formatting.c use StringInfos for output buffers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Make formatting.c use StringInfos for output buffers
Date: 2026-08-20 16:39:50
Message-ID: 3760457.1787243990@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> On 13/08/2026 20:24, Tom Lane wrote:
>> The main problem with this proposal is that it makes these functions
>> a little slower, apparently because calling snprintf() via
>> AppendStringInfo() is slower than calling it directly. After the
>> performance hacking in 0004, what I see is that float8_to_char
>> and numeric_to_number are the same speed or a little faster than
>> before, but timestamptz_to_char is still around 10% slower in
>> a tight-loop benchmark.

> Attached is another micro-optimization that makes a surprisingly big
> difference on my laptop (10% - 20%). In a nutshell, have a fast-path for
> when a constant character in the format string is a one byte character.

Oh, nice! That fix alone makes timestamptz_to_char faster than it
is on master, which is as far as my ambition extends right now.
I'll proceed with this, and if someone else feels like taking up
your other micro-optimization ideas, feel free.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Corey Huinker 2026-08-20 16:28:30 Re: use of SPI by postgresImportForeignStatistics