Re: Make formatting.c use StringInfos for output buffers - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Make formatting.c use StringInfos for output buffers
Date
Msg-id 3760457.1787243990@sss.pgh.pa.us
Whole thread
In response to Make formatting.c use StringInfos for output buffers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Heikki Linnakangas <hlinnaka@iki.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



pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Re: use of SPI by postgresImportForeignStatistics
Next
From: Peter Geoghegan
Date:
Subject: Re: GIN page deletion and page recycling bugs