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.96) (envelope-from ) id 1x3xRV-006mub-33 for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 15:09:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3xRU-007roc-2y for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 15:09:00 +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.96) (envelope-from ) id 1x3xRU-007roT-1J for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2026 15:09:00 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x3xRS-00000004c8y-2Q2Y for pgsql-hackers@postgresql.org; Tue, 08 Sep 2026 15:08:59 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 590031400054; Tue, 8 Sep 2026 11:08:57 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-02.internal (MEProxy); Tue, 08 Sep 2026 11:08:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding: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=1788880137; x=1788966537; bh=EHg+IDkJmkC3viEB9UOixUEG7ABkGMeqRh1W+58DNso=; b= DZB9HjelLNS4PYaQNBvgQgqemgfMbOjC8nUET9fev3IqQROAj7hS6bI5psUn7e8j 8RumF/D6l8XR1R11OU5txoO3D4OZj/ho5D/IhAA51rDT0IVDdMMveHGJSMMvKFYq bDzqbUm7IDUO7YjMcMxOwZCLD5ANm1RGgkTMIJ+a+at4RHlih3Fec4wtkt5lHSPH UhYEQou57WJUhlkp7vGbt3Az7DsVgeC5NhotwAC+DLiComHwauZeN/bBWCFdDRlZ 5prMuJU4nFZlfAYYstXDApegeTPbqlm5yOJS9aCjpG68Nl/dgzwlRwLkG4shS2qP Jop92QGw5/qaJh5RaoSkeg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788880137; x= 1788966537; bh=EHg+IDkJmkC3viEB9UOixUEG7ABkGMeqRh1W+58DNso=; b=o aQCH+JBKN04kICGjS7627MdRzVrCe8/x8BwyMTkr3T5vn7aSkI48Sd33GMjOzZAd 4F2mAUVUUx9cH4VkxCBjL8xw7ZMuJlD9GbzSTscJO1ASTbU7Jvzhjcz0L7knHIo8 pLSZqXLnigxar0zZYM0IIod1HQstIciBDvo62YJu6E5CffzMsPqu5RsGhRXp0rRh 5LByJP40fnV3E8hD/09HILHzH/CR0hOKTZMSE1Ykw7zpKXos6BC2e5VBXPDjZECm 90eHFaKQWMs1c6ICnBO+n9lteJWCTPMfQazho4SHz3PYPVQRQ2JOGXF/awJ6Inwk 979hORXGRdVQTRD3Trfdg== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGSLfA3WJPGP23mKybucqFYGnFLnddmyXjldnWpHBmo9nv1xClML23PIvbvyXAAOq 5Zkersug5b+3iw8YmiqdGzi6BEowbtPy8wcbyL7g1ztVf/C5cd3ath9R2Oezl2nPyroeZW f29ECqrw3IN0OBb6o1cvxv6QrNaRXsyTzp4Ei9WAi68V3uIx5T3h37FeqMWBIuX8aSvt/7 UnCVOhajk/VGc9eKgh9Bnrohs3xWET/BOoRgW9TMDifEjZIGwbsnLo9lFjt//jcVTqBN3R r2sRSdaf9bK1tUhNGwOvyFFZQ1R+ZubgnaCGBqDt1aOhXNetOXZ0wIZTEm3oW71NweOsb9 amHlpJVb/wzSUAsPcwTLg2uWOKg4WleyGWJNPQ8GYCdpkHNdXCmCwm0HRMSpWCuMI4XwDv 88Ljtzk/XSJ9mX5PCgKa7M7neslXhTJDLWiZnEqCT6s6zHBtkGIkboxhb0s8x5OrxYFLuA ZFvBkbFLaQ3HlC5dxYJNQLpHOxi4qhXk6RUHS2SkvO7X1b7xR9KUjqSHcAglDbwbDjQ9C+ +SNBkwBbSTQWeUYBut62qL9CeaQtQQNaZk6Il7jphegAyCe/lDpcdPBjIoVkzry1HoiJfe 8vKZNKeTdN63c9w3RYgXANwmowLeyzMt6+C2tidMJ9SH2XDZtfjJ3kNJ+xfg X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C17E2700069; Tue, 8 Sep 2026 11:08:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Tue, 08 Sep 2026 11:08:36 -0400 From: "Greg Burd" To: "Nazir Bilal Yavuz" , "Nathan Bossart" Cc: "KAZAR Ayoub" , "Neil Conway" , "Andrew Dunstan" , "Shinya Kato" , pgsql-hackers Message-Id: <9434f7bb-5865-4828-9f23-1dd30e50aaac@app.fastmail.com> In-Reply-To: References: <43de48dc-701b-4735-881b-50bca6870f39@app.fastmail.com> <78e736c8-7f4e-46c2-9fcf-a6839e393d64@app.fastmail.com> Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hey Nazir, Nathan, Thanks for turning this around so fast. The v1 looks right to me. Checking only for the backslash and letting the scalar parser do the actual marker recognition is the right call. Trying to detect a full '\.' in the SIMD helper would mean duplicating the CRLF handling and the "marker is not alone on its line" checks, and that logic is fiddly enough that I'd rather it live in exactly one place. The !is_csv guard is also correctly scoped: the scalar path only treats '\' / '\.' specially in text mode (copyfromparse.c, "if (c == '\\' && !is_csv)"), so CSV never had a buffered marker to worry about and doesn't need the check. On the perf side, I read your 1-2% on TEXT-wide as the expected cost: the tail check bails to scalar on any backslash in the last < sizeof(Vector8) bytes, not just on a real marker, so escaped data near a buffer boundary gives up SIMD for that refill. It re-enables on the next line, so it's confined to boundaries, and as you say it's still well ahead of pre-SIMD. I think that's the right trade; correctness wins here. Might be worth a sentence in the commit message noting the small text-path cost so it's on the record. One thing I'd like to see land with the fix: a test. I'll see if I can knock one out if you don't first. best, -greg