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 1rcfAX-001KUh-B6 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 05:29:21 +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 1rcfAV-002u3u-PY for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 05:29:20 +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 1rcfAV-002u3m-GC for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 05:29:19 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcfAR-000DMd-C8 for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 05:29:18 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id B66615C009D; Wed, 21 Feb 2024 00:29:14 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 21 Feb 2024 00:29:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708493354; x=1708579754; bh=8uwdVGRBIg vHwdX/EnM5wnlT3QxYSEfNe3bkcTzoT3A=; b=VK6YooP0UylHhwvDhHAqagZ+2a WBFAa0SY+mk+E5pkqRPHgE7+xcE8cCij6CS4Py3MQiqlsZLKC7mTagBqjSQDXKQZ 8WHoDYHQuTMb3SwTkruME88uF7jzTba8V+xaG5hKpO3/j+nvWqPiFgamY0r2XfZG Ib8BLxkSjbViCoJa8/1kNVW5eNtxG2lYvR0aMRajs6XtwePdAE1npNeJYGCkmlcq zRp6QwEqwxzavDZcNB9DKYP57Vpi2DFXHzPMj5glX49at0Kuz+F5tMHAOfQl4hr0 Inol8cdCWr0XfG+67ywHqi7zuVj6GgbtRFcrF2MRoNYyP9SzCNNnAVqIv9FQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708493354; x=1708579754; bh=8uwdVGRBIgvHwdX/EnM5wnlT3QxY SEfNe3bkcTzoT3A=; b=ri2ZHPpl4I7g8Wx6LVggHwR2YQe27bL+BmiU4BXDZEXb oILqxzM/jkXThgq5GPgf2rWccizzF9dzkSRKEaGiQxiuCIztQzE1ipGNSv2kQ/4L HDpA9rtpn8/ajlvuaDQktOQC4zv70qxOxyq7n6Wr6oUn2scqTLDTOF3TSkPekr1g pJzT5/wvXxCiqXgCVow+kYQJHu1+6Dqj6IcIDcXceOzC5H3Ez1DzTCKG+UkMk3CM MF81X4gT5+QmL9ttav4kPi7WM2706GhVfKuUa2ZK3+vrkb1Q0Ynz15YXDZj4hwVf UKIO0I07k7FB87BCvyeGe7XCiaKMlO+M3FvQ0Ch9SA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedugdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Feb 2024 00:29:13 -0500 (EST) Date: Wed, 21 Feb 2024 14:29:05 +0900 From: Michael Paquier To: Laurenz Albe Cc: Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Speeding up COPY TO for uuids and arrays Message-ID: References: <679d5455cbbb0af667ccb753da51a475bae1eaed.camel@cybertec.at> <20240217202433.b4f3hbvu45ntld7c@awork3.anarazel.de> <1339b52e16d4977ce59a9d3e91837c1033713930.camel@cybertec.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="VZaABRGs7GrUiyvO" Content-Disposition: inline In-Reply-To: <1339b52e16d4977ce59a9d3e91837c1033713930.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --VZaABRGs7GrUiyvO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 19, 2024 at 03:08:45PM +0100, Laurenz Albe wrote: > On Sat, 2024-02-17 at 12:24 -0800, Andres Freund wrote: >> I wonder if we should move the core part for converting to hex to numutils.c, >> we already have code the for the inverse. There does seem to be further >> optimization potential in the conversion, and that seems better done somewhere >> central rather than one type's output function. OTOH, it might not be worth >> it, given the need to add the dashes. > > I thought about it, but then decided not to do that. > Calling a function that converts the bytes to hex and then adding the > hyphens will slow down processing, and I think the code savings would be > minimal at best. Yeah, I'm not sure either if that's worth doing, the current conversion code is simple enough. I'd be curious to hear about ideas to optimize that more locally, though. I was curious about the UUID one, and COPYing out 10M rows with a single UUID attribute brings down the runtime of a COPY from 3.8s to 2.3s here on a simple benchmark, with uuid_out showing up at the top of profiles easily on HEAD. Some references for HEAD: 31.63% 5300 postgres postgres [.] uuid_out 19.79% 3316 postgres postgres [.] appendStringInfoChar 11.27% 1887 postgres postgres [.] CopyAttributeOutText 6.36% 1065 postgres postgres [.] pgstat_progress_update_param And with the patch for uuid_out: 22.66% 2147 postgres postgres [.] CopyAttributeOutText 12.99% 1231 postgres postgres [.] uuid_out 11.41% 1081 postgres postgres [.] pgstat_progress_update_param 4.79% 454 postgres postgres [.] CopyOneRowTo That's very good, so I'd like to apply this part. Let me know if there are any objections. -- Michael --VZaABRGs7GrUiyvO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmXViiEACgkQnvQgOdby QH1tsQ//X+cTSYbY+kppMogs0Q1LIySWbgIpTk5WSU8kax293lxdH0Hc8t7mQYMY cPXJFiH0QfVdxl38PnaAccc2wkoTgfHQWZ2rhOiZERuU0PvHFAy5r78PvNPOjLIf u38S/N5QuG4fi0OOQblZ4Bd9NoZHVHu9f7Nzg3ij6DJuLp2A9M3+Pc8ZUpNoWV2D EYWvSLKZvT19dfKLNksist7Lr8XzftHIBhIAo97U1WJTD3qjOAWDMvqhYkHc+bYL MlNDbHZZiSU27ki++4KZbSuetkkbA5T2pAD73iIsCywtN81LM82NjAyBWTSdN++D kzdObCuzPwzvCL7c1TSm/m+9rURDRj3RiJcWemLHNkQbo3GKBXT7/n/AjQLrxK7W OeSOF3YqhRCgOLZDh+CpEb2RdvUbta0hdIH0PWjH0IJTSUt+nDbIhvLSmyOygY9m FSDg8XNULhGWccWthwuvLjiUy/iQKVt/MjZzO1BtYzdx2eDfyh/8AjEsRD1uSKo8 DuwUBK9bl1kp5J7x/NBt5TlLp+4tfYWddlX5hiu+eS+/gPVw5d6e8ZagyA96as87 nqAq0dioa5lBDqZ2kYb7xPvVlrE4kcZ037OYEHK3BtCqKRV+3aj2o4g4NOlGSx06 bTL0wnAkpz1M/vdDaWZYS2XqyywF0E5X6PMTdSB0/8PAwQ+8nrs= =a84p -----END PGP SIGNATURE----- --VZaABRGs7GrUiyvO--