Re: Emitting JSON to file using COPY TO
Joe Conway <mail@joeconway.com>
From: Joe Conway <mail@joeconway.com>
To: Nathan Bossart <nathandbossart@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>, Davin Shearer <davin@apache.org>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-12-07T12:15:28Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add option force_array for COPY JSON FORMAT
- 4c0390ac53b7 19 (unreleased) landed
-
json format for COPY TO
- 7dadd38cda95 19 (unreleased) landed
-
introduce CopyFormat, refactor CopyFormatOptions
- a2145605ee3d 19 (unreleased) landed
-
Doc: add IDs to copy.sgml's <varlistentry> and <refsect1>
- e4018f891dec 19 (unreleased) cited
On 12/6/23 21:56, Nathan Bossart wrote: > On Wed, Dec 06, 2023 at 03:20:46PM -0500, Tom Lane wrote: >> If Nathan's perf results hold up elsewhere, it seems like some >> micro-optimization around the text-pushing (appendStringInfoString) >> might be more useful than caching. The 7% spent in cache lookups >> could be worth going after later, but it's not the top of the list. > > Hah, it turns out my benchmark of 110M integers really stresses the > JSONTYPE_NUMERIC path in datum_to_json_internal(). That particular path > calls strlen() twice: once for IsValidJsonNumber(), and once in > appendStringInfoString(). If I save the result from IsValidJsonNumber() > and give it to appendBinaryStringInfo() instead, the COPY goes ~8% faster. > It's probably worth giving datum_to_json_internal() a closer look in a new > thread. Yep, after looking through that code I was going to make the point that your 11 integer test was over indexing on that one type. I am sure there are other micro-optimizations to be made here, but I also think that it is outside the scope of the COPY TO JSON patch. -- Joe Conway PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com