pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Davin Shearer <davin@apache.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Emitting JSON to file using COPY TO
Date: Thu, 7 Dec 2023 07:15:28 -0500
Message-ID: <685e4c62-b584-4a0b-aee1-6ff77fa71aba@joeconway.com> (raw)
In-Reply-To: <20231207025622.GA3011676@nathanxps13>
References: <7a60faf6-e7f1-419d-aee6-10a78ea2fe81@joeconway.com>
	<2e7ff718-895d-83fc-46f7-be25e23b23b4@dunslane.net>
	<!bbf922c5-f571-483e-a2c6-2730b02183fe@joeconway.com>
	<1104915.1701877459@sss.pgh.pa.us>
	<19a5f9d8-bd1f-9!e51-0f5b-510c1189a8a7@dunslane.net>
	<1110690.1701880139@sss.pgh.pa.us>
	<20231206163349.GA2873889@nathanxps13>
	<20231206164439.GC2873889@nathanxps13>
	<77312d02-9325-4f14-9fe0-2746c2ee12bc@joeconway.com>
	<1136975.1701894046@sss.pgh.pa.us>
	<20231207025622.GA3011676@nathanxps13>

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






view thread (163+ messages)  latest in thread

Message-ID: <685e4c62-b584-4a0b-aee1-6ff77fa71aba@joeconway.com>
Permalink:  ../685e4c62-b584-4a0b-aee1-6ff77fa71aba@joeconway.com/
Also on:    postgresql.org/message-id/685e4c62-b584-4a0b-aee1-6ff77fa71aba@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: mail@joeconway.com, nathandbossart@gmail.com, tgl@sss.pgh.pa.us, andrew@dunslane.net, davin@apache.org, pgsql-hackers@postgresql.org
  Subject: Re: Emitting JSON to file using COPY TO
  In-Reply-To: <685e4c62-b584-4a0b-aee1-6ff77fa71aba@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox