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 1rSrkG-00GQdD-UL for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2024 04:53:45 +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 1rSrkF-00CB5z-Lg for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2024 04:53:43 +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 1rSrkF-00CB5p-CC for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2024 04:53:43 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSrkC-003F9M-TD for pgsql-hackers@postgresql.org; Thu, 25 Jan 2024 04:53:42 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5100C5C013B; Wed, 24 Jan 2024 23:53:40 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 24 Jan 2024 23:53:40 -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=fm3; t=1706158420; x=1706244820; bh=6NbrMG0A0O Ubr9PtOxW1PIbcrI1jfZNQTa2F3dx+lto=; b=UisLKfounwuPWTbeo5veSBnIqz yI3D3dFGYIiXBzTcYLhD4V4Im9nDcHAvYJjP2UQFPoNvIAAs6zPh3VuLnYoOWq3i h/WiscNJ7KdfRYYZbm1eKkhwiTGNG3tkw2Q/UfnK1Zbo0Hvl6jUJq15eCxOH8kFZ PFy4hwlwmasZt6qp4TpRQOu0mmt9upeFk/cEwnjWtRZSpujVe+UPVLXajFjcB7+y OkhmY7Wa0xvEiQDBpMY8JiBja92OT8cWtnKsjK9MUH95Zg9E/TfLFEosPSOsv6fX knf07dfYWNJC5xcF/z5fp869Ipl+j05BG9nPQrZK9kSObjllmAeWZ+vO1v9g== 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= fm3; t=1706158420; x=1706244820; bh=6NbrMG0A0OUbr9PtOxW1PIbcrI1j fZNQTa2F3dx+lto=; b=H1dMU5rZSddryFdYkE6DUNCubziE5SCmSrJaonSw6Llf YyP3/8NGj8R3gi17Qn+NqAik15UtsDBGDUt6Br42C36/ebL5YjbQXgP7uSt6ii3o kJK2EbFx1+3k7l3D/FwpKQHQBXgpzJduQcIfIG2lJ/xE99pel1dmy9SzHb2ilsQq 0F36SurJ47l1eAYMB2X78dv8QFmTJKKebUgIaRF2l05triUkcO5dpDdolgWOivkH l/GSgDX2c5cvdJrmnKRVNMBek5sqOoiO9l1RYo7V/X7elzvqRFsa/bfUkASAw9pn LUuo0omcVpkELMBuVORCuGySibSkMZG5LKxeiq04Gw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelvddgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 Jan 2024 23:53:36 -0500 (EST) Date: Thu, 25 Jan 2024 13:53:30 +0900 From: Michael Paquier To: Masahiko Sawada Cc: Sutou Kouhei , andrew@dunslane.net, zhjwpku@gmail.com, nathandbossart@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations Message-ID: References: <20240124.144936.67229716500876806.kou@clear-code.com> <10025bac-158c-ffe7-fbec-32b42629121f@dunslane.net> <20240124.231726.1771099323950062661.kou@clear-code.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wbHB1Yjf+rRVHMOc" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --wbHB1Yjf+rRVHMOc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024 at 01:36:03PM +0900, Masahiko Sawada wrote: > Hmm I can see a similar trend that Suto-san had; the binary format got > slightly faster whereas both text and csv format has small regression > (4%~5%). I think that the improvement for binary came from the fact > that we removed "if (cstate->opts.binary)" branches from the original > CopyOneRowTo(). I've experimented with a similar optimization for csv > and text format; have different callbacks for text and csv format and > remove "if (cstate->opts.csv_mode)" branches. I've attached a patch > for that. Here are results: >=20 > HEAD w/ 0001 patch + remove branches: > binary 2824.502 ms > text 2715.264 ms > csv 2803.381 ms >=20 > The numbers look better now. I'm not sure these are within a noise > range but it might be worth considering having different callbacks for > text and csv formats. Interesting. Your numbers imply a 0.3% speedup for text, 0.7% speedup for csv and 0.9% speedup for binary, which may be around the noise range assuming a ~1% range. While this does not imply a regression, that seems worth the duplication IMO. The patch had better document the reason why the split is done, as well. CopyFromTextOneRow() has also specific branches for binary and non-binary removed in 0005, so assuming that I/O is not a bottleneck, the operation would be faster because we would not evaluate this "if" condition for each row. Wouldn't we also see improvements for COPY FROM with short row values, say when mounting PGDATA into a tmpfs/ramfs? -- Michael --wbHB1Yjf+rRVHMOc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmWx6UoACgkQnvQgOdby QH0D/A/9EB1nYIJhPJMfAo7imVCTiUy9teH0YWBuv9m8cJUa4YeViK9N4z7Jzh8u 1dOZGeJnCwwoWPDqJubIvTJ0D7KtP1c9tqz7msZTBHFbXH0JZoD8s5M7aJauvDns 6Lf+XZcnZ/mVXPxxo2THMqD3tjRapx8e0chyyLvzh7Gd642Wull5ElERjZV25mtO Iv10YAkcxWBe/qhpp177IieK0mdIPQIiAeck8woHX/g0jflQY5OS9j7lFrcoqRc4 0+CBV3FwCqxHHwwHHCUlH+Rb9GN7CaYhenL1Oq2oYyD8UT3lHny9RwcpuT31K8QL kzLDfsbVI0skcpqSK5iHsGdNN7nJ/S778GEiSG70kyMs/gtp7uHk9hQSNKjszXjY eTVywBuf4aLvLpHveGfEHrvn3Z8L/iK7P9/JSWtQAtc9KzVJ+3q3DKI2vHo4Shzp c/c92nQLasfXPZMT47br4YT5LIrmXHhjfSPWMBzRss5TXcNWfgywuHhnYX7aP3CE QV1iUdhnqxSxFnOn9RZ37bS3w+abZyeoUMKN1/Az+DTE/OhuBXmoFKauZc8Upw8z cOxXWropSep2LXsuCh4aJUmZfRlC0PYarvBvjEl4CQ6KFWQolSP9V+oEHePMvVvW onVpg3Lk7ntmixgiohMs5XFIX/3H9JPCPgAZhXvB1W2f6eKdZm0= =+pnR -----END PGP SIGNATURE----- --wbHB1Yjf+rRVHMOc--