Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAyOC-008wA4-99 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 20:21:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rAyOA-00CMcH-DP for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 20:20:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAyOA-00CMc9-3t for pgsql-hackers@lists.postgresql.org; Wed, 06 Dec 2023 20:20:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAyO3-0098RW-5j for pgsql-hackers@postgresql.org; Wed, 06 Dec 2023 20:20:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B6KKk6F1136976; Wed, 6 Dec 2023 15:20:46 -0500 From: Tom Lane To: Joe Conway cc: Nathan Bossart , Andrew Dunstan , Davin Shearer , PostgreSQL-development Subject: Re: Emitting JSON to file using COPY TO In-reply-to: <77312d02-9325-4f14-9fe0-2746c2ee12bc@joeconway.com> References: <926ff917-8371-40ec-b5e6-ab7b0e09bdc5@joeconway.com> <315b81d4-4b67-7828-0355-3808cd14acd1@dunslane.net> <7a60faf6-e7f1-419d-aee6-10a78ea2fe81@joeconway.com> <2e7ff718-895d-83fc-46f7-be25e23b23b4@dunslane.net> <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> Comments: In-reply-to Joe Conway message dated "Wed, 06 Dec 2023 14:48:52 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1136974.1701894046.1@sss.pgh.pa.us> Date: Wed, 06 Dec 2023 15:20:46 -0500 Message-ID: <1136975.1701894046@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Joe Conway writes: > I'll see if I can add some caching to composite_to_json(), but based on > the relative data size it does not sound like there is much performance > left on the table to go after, no? 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. The output size difference does say that maybe we should pay some attention to the nearby request to not always label every field. Perhaps there should be an option for each row to transform to a JSON array rather than an object? regards, tom lane