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 1wCpt4-002LvZ-2R for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 02:21:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCpt2-00E56w-2m for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 02:21:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wCpt2-00E56o-1q for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 02:21:53 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wCpt1-000000018Ve-1wya for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 02:21:53 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-43cf906b007so3574023f8f.0 for ; Tue, 14 Apr 2026 19:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776219709; cv=none; d=google.com; s=arc-20240605; b=J58TmektlwICVm6xvNnfOoqWgU3x2P43XrssfEBRk7+LlEFdZiRmHEgB28z0tPnSkC 1aP+FT58vUXME1KVk3llRjOkiDOXbUPmlS4vUguiiKKfvT5K0qnmXGU4UPdbKZ26idSk xzQFit1wRPqy+bGAfOIA5HNFI0+gPjNL8xwUS5pQXECHVxy3QmDTzkBl5MBZoD2siGiE Hv9dX7dIA1cI8lErQpqrbNuKY7FLTbZiNPV1NRZDSQC001fb4i5aUk60M3g98yDNzZqT iosiGexgWNX3A0sNmbz/f0/9bmbkAtiLCErO6xST1O7iXZAPmCRvupgcmvtcIu7/I2OC vVUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=/7e/Y9yVc7XhI0h+tTymOzCMNx0Wqu4JvshOx9GeSs4=; fh=6nQ+cA4LCqkSCHU8/vBvvFmg74AuTPy1nHM6G2uDemg=; b=dJQ59pT/Z4puhggrvLhLA6iiqx4BwFMQIcQfvJo5Jne5fl9ztaCbFetri/DPgZX+bK Lus2tjH7Bm6dif9GP+eVM38z4gmt8BUeU8NdHi1O+muptzuCiAgqO55bY8ZqiClk5Hlw h7cdzQfCdowr3nlq21Djpxc6E1+P1mBMTy8f4JIk8wd7PFhHbfTjsaEcQre6OrO4m7uS gnSVBSjdBGghw/r3whW+9Pwh/Mcr22afYNtjP8UdkClZS1e4ropRHI7oUI9ntGVAS80u SAX/lrenRFT74WZ4zDEGSxD3qQ2kJSYCz7PdYTuurPfhAQICbofZ8ORp7LpBS2hxzA8b QQ+g==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776219709; x=1776824509; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/7e/Y9yVc7XhI0h+tTymOzCMNx0Wqu4JvshOx9GeSs4=; b=qjQdhiy880qnSqRba/VmAwc4wh0p3Pqtru3OKV9TIq/Sgzngh1Sz1uOWOl+MhASCNq MUUjtCvnsHt/nlAyaVt1gxKqKJbtehtJNFPnkI4jFOKwZbHDEx4QjOXMsSIu5ZYa1Z+X VkMyn67ENH6KCQps93GPs5koi+Xx0XWzXQYExd/b68b0VBoEokFnzihX1z6Er+sCInMo HMS2/hlBPnSF27F5HhscvsmbG7cESRHtrB6SBeFlm3Tj/gUT80pExsx+hG9l75A2SGl8 b+/QDasN66tE0G4eoDBGx8Q9mm+tRvbdYoVAllGZvPofF1h4vqp2+pmMrL7Rjv5/6Mil f4XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776219709; x=1776824509; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/7e/Y9yVc7XhI0h+tTymOzCMNx0Wqu4JvshOx9GeSs4=; b=XS835RmD8IgSn6ciEhhkrKGTIw6Wb+dQkJd/OeWIsbCl5+pOnYqv32fCLd/h1tDAu+ z2G/FKO0PYQSfTbcVAQbNtZs97KB/4Hxl55ve2a++ozJv0Pweb1jCdOPr/nKIPy9qBbE HXlsTn1HTFHjOYGi3JTuqcgF1HitQCScbG6BEXKRNcOAtRxbiD8JG+BAf2rGuf8ywnw5 qe2MRA+ENA4Ju2mzFJRXVh4TcA5m1WiSimQsP2daFhSEHjBhI+4h04heSG/VVAKSMZTo 9QqNdKpAsELqKmTSi1Refs/6zOs01WQBPnAFhS8ecSO/1ZOok+8Vmo3jaXCiU8yVVKO6 OfxA== X-Forwarded-Encrypted: i=1; AFNElJ+rMKB1//lvnVRFmRHG/hGCNCjP5B/8Tv7WP3OZO2g5BjJPRwwk6k9n4GnQuok/GWxy7DHUByKtZEG4gOA2@lists.postgresql.org X-Gm-Message-State: AOJu0YzJgbBLqaPUi3VrFh28p4Av4Yt0kNI2Rgo2WN9ir8Crw4b9rFYn p5nI1a0np7Uppjv9de2RyDR+RIMjgHZYKIbc/s6+k6DunMSzXRbjM2msyvPT6l+fNYiPC48JP3o mv068bP6ft/gC2alVa/j2VkllgeJkIAQ= X-Gm-Gg: AeBDiesu3YWaU/buqXiF0WNltPZjR9sHFCiSkoshmBDT0YAygkq3hDgIzEXsKgidfgY +71937OrA9nTbSbJ3qxPZJS/grDMtkRWAV5P8OcCacuvgLRmoHiVtLJ2hMFpbLyMQhrJw7bi402 6wZCepnjPXrU8/7rInSRNWqwH8erhyye8zLQKtOoRcVWcY/4lnRYpOZxmpbgF9bjrowLwbgDZxs OLVexMdMkSWIFp394pYHcObDljepsErHho2I+trhYBMHWvfSiLR2Z/T/WPJ/jya/i/KCT7yxTPP 7dCd9RajqZ6EPXEspQ4eGifTTn6TmjemYni+4X/i/hBYyM0nJsALP3+fjGDJnaViNkifgZ95Eqe ASnx5UlzU X-Received: by 2002:a05:6000:604:b0:43d:7146:ccca with SMTP id ffacd0b85a97d-43d7146cd60mr18242341f8f.45.1776219708505; Tue, 14 Apr 2026 19:21:48 -0700 (PDT) MIME-Version: 1.0 References: <278B9FE3-F349-4494-99C5-483105C1C999@gmail.com> <1900289.1776212948@sss.pgh.pa.us> In-Reply-To: <1900289.1776212948@sss.pgh.pa.us> From: David Rowley Date: Wed, 15 Apr 2026 14:21:36 +1200 X-Gm-Features: AQROBzBAFxhdPW5K1Qzgx6K6I3zEqMG1hY2ErFSYLlnf42nqsGnXa8hyBcRPkX4 Message-ID: Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets To: Tom Lane Cc: Chao Li , PostgreSQL Developers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 15 Apr 2026 at 12:29, Tom Lane wrote: > I question the decision to make this change the set in-place. > Wouldn't it be cheaper and less surprise-prone to always make > a copy? I'd not considered surprise-prone as an aspect. I understand we have bms_join and bms_union, which do the same thing if you only care about the value of the result and not what happens to the inputs. So I didn't think I was introducing anything too surpising given we've got various other Bitmapset functions that modify the input in-place. My expectation there was that people are used to checking what the behaviour of the bitmapset function is. For the current use cases of the function in the patch, I agree that it would likely be better for performance if the new function allocated a new set. It was more a question of whether we want to throw away performance for other cases which are fine with an in-place update and have a positive offset. Those will never repalloc(). I didn't really know the answer. I suspect with the current patch that each of the existing cases will be faster than today's bms_next_member loops, regardless. When I wrote the function, I was mainly thinking of the new use-case that I was working on, which won't require any palloc() or repalloc() with the current design. Since I was adding that to a fairly common code path, I thought I had more of a chance of not having to jump through too many hoops to ensure I don't cause any performance regressions. In short, I don't really know what's best. I'm certainly open to changing it if someone comes up with a good reason to do it the other way. Maybe catering for the majority of callers is a good enough reason to change it. David