On Tue, 27 Feb 2024 at 00:31, Ivan Trofimov <i.trofi...@yandex.ru> wrote: > I see now that I failed to express myself clearly: it's not a per-query > overhead, but rather a per-result-field one.
I'm fairly sympathetic to decreasing the overhead of any per-row operation. And looking at the code, it doesn't surprise me that PQfnumber shows up so big in your profile. I think it would probably make sense to introduce a PQfnumber variant that does not do the downcasing/quote handling (called e.g. PQfnumberRaw). However, I do think you could convert this per-row overhead in your case to per-query overhead by caching the result of PQfnumber for each unique C++ string_view. Afaict that should solve your performance problem.