Improve speed of timestamp/time/date output functions.
Tom Lane <tgl@sss.pgh.pa.us>
Improve speed of timestamp/time/date output functions. It seems that sprintf(), at least in glibc's version, is unreasonably slow compared to hand-rolled code for printing integers. Replacing most uses of sprintf() in the datetime.c output functions with special-purpose code turns out to give more than a 2X speedup in COPY of a table with a single timestamp column; which is pretty impressive considering all the other logic in that code path. David Rowley and Andres Freund, reviewed by Peter Geoghegan and myself
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/datetime.c | modified | +261 −128 |
| src/backend/utils/adt/numutils.c | modified | +161 −0 |
| src/include/utils/builtins.h | modified | +2 −0 |