Re: Emitting JSON to file using COPY TO
От | Andrew Dunstan |
---|---|
Тема | Re: Emitting JSON to file using COPY TO |
Дата | |
Msg-id | 6603ea04-8ec3-67b2-e9f6-e00fd0e46858@dunslane.net обсуждение исходный текст |
Ответ на | Re: Emitting JSON to file using COPY TO (Joe Conway <mail@joeconway.com>) |
Ответы |
Re: Emitting JSON to file using COPY TO
|
Список | pgsql-hackers |
On 2023-12-03 Su 14:24, Joe Conway wrote: > On 12/3/23 11:03, Joe Conway wrote: >> On 12/3/23 10:10, Andrew Dunstan wrote: >>> I realize this is just a POC, but I'd prefer to see >>> composite_to_json() >>> not exposed. You could use the already public datum_to_json() instead, >>> passing JSONTYPE_COMPOSITE and F_RECORD_OUT as the second and third >>> arguments. >> >> Ok, thanks, will do > > Just FYI, this change does loose some performance in my not massively > scientific A/B/A test: > > 8<--------------------------- > -- with datum_to_json() > test=# \timing > Timing is on. > test=# copy foo to '/tmp/buf' (format json, force_array); > COPY 10000000 > Time: 37196.898 ms (00:37.197) > Time: 37408.161 ms (00:37.408) > Time: 38393.309 ms (00:38.393) > Time: 36855.438 ms (00:36.855) > Time: 37806.280 ms (00:37.806) > > Avg = 37532 > > -- original patch > test=# \timing > Timing is on. > test=# copy foo to '/tmp/buf' (format json, force_array); > COPY 10000000 > Time: 37426.207 ms (00:37.426) > Time: 36068.187 ms (00:36.068) > Time: 38285.252 ms (00:38.285) > Time: 36971.042 ms (00:36.971) > Time: 35690.822 ms (00:35.691) > > Avg = 36888 > > -- with datum_to_json() > test=# \timing > Timing is on. > test=# copy foo to '/tmp/buf' (format json, force_array); > COPY 10000000 > Time: 39083.467 ms (00:39.083) > Time: 37249.326 ms (00:37.249) > Time: 38529.721 ms (00:38.530) > Time: 38704.920 ms (00:38.705) > Time: 39001.326 ms (00:39.001) > > Avg = 38513 > 8<--------------------------- > > That is somewhere in the 3% range. I assume it's because datum_to_json() constructs a text value from which you then need to extract the cstring, whereas composite_to_json(), just gives you back the stringinfo. I guess that's a good enough reason to go with exposing composite_to_json(). cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: