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 1w7558-004wQJ-1r for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 05:22:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7555-001LgC-1W for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 05:22:31 +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 1w7555-001Lg3-0U for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 05:22:31 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w754x-00000001wOu-3A3a for pgsql-hackers@postgresql.org; Mon, 30 Mar 2026 05:22:26 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-8d006a80ccbso532777185a.2 for ; Sun, 29 Mar 2026 22:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774848142; cv=none; d=google.com; s=arc-20240605; b=hlRA8mYRu1IXT22elOf256/dvUFzjYGo/WUbVzvliDj8ltnzu31spwi+2CSPAbZXwk ACzIyEMYuxrw7fjO409fxvt8R5XNiKXLV5amW0te9SEJltLp3YpRtmV5nl1OqCwzSWTm eYisFJKX23Q2vco+8iMLLPotWzDxP1GKG9hGMyrqjyXMYPon9Kg9O/LngMfFBz9qPmY6 fYmey1cbhZlSnxdVzN9ODpIdhZOuR+IcHAWaKA7e4T5QuD+b62SKPOK2lHxvRzze5Wok umsW1O4szRRQKS3bMdMikVNPmCiXVrRRLnKvGYST8/Aig8hBwY4hXGJ1go3RaAOPgS/3 1mBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nwxlrnJHQ6UMwR5dF1LtiswdTdev68DE17++A5ECg/g=; fh=z5fTDNfgyAAhGtnTEvbqTpuYLAweN3/E82Q6kbZeBUo=; b=SeJNOgIzIKWCwbtXd4WQIVQXqaQjccpLmIiIVIkRGRLpkT1whIvxsfdb/0KcCCyEk6 LZwW3YR+xxEoAMJoDRCgqW082LTsxdniF0NDfGZ44VWTqJSPNN/td7EwNERWlVu2jenQ G55UuweFu2PVp5WHGdAdzjTRD5QrXzLTvpH5RuNggwdIf4KvgzwzWbTl24Ms7h92bNbA y942n0T7kCOv76xT2s44kBh9LnS28phT6JCjNxE5K5TBKnZgEQdKj6cRabagF32tMgXS 2QXKKrC3pSpZrwuonKL8ioBu4GhmgN5tkcR7wfAM97K/bv0ep1TwSZdXkNTLHSy9SI42 NYcw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fittl.com; s=google; t=1774848142; x=1775452942; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nwxlrnJHQ6UMwR5dF1LtiswdTdev68DE17++A5ECg/g=; b=LGJX7NJwrOM5sbHjSErKHCxU8LvixCvfmGKopg0nRYpyS3h1oylUh3AScKuBbSzsTO huz+JVlEydhMy6fwf/ETJb6SR91AgoyPDNOMxpmZQfkmmry6J8UXoOqNnFGQD/MiwjF/ KCADoem34MIAvV4lhUvBckFD0dJ+W+nXrf8Os= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774848142; x=1775452942; h=content-transfer-encoding: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=nwxlrnJHQ6UMwR5dF1LtiswdTdev68DE17++A5ECg/g=; b=BXdPDG0LtVvvub8UUex1UtzJKalpUu+NIjy4XwWXCUSrmpBjgGonBitj/Uiw5XdnT7 7KsyRNsGNmeuyWwIKu2wm9zkpkqnxK+9153dR02x4wkR3ZHe+N80FBTJYP2pxQuO+M5O yzkSkT2e0UzPBEQK8U80w6P6su8i010bwjpsNk8oTRbaGlAKd9gl/X6rpc//u4D7/+pa JIbba0ohBtKHPUunXCDVQPk+F2fq0o02IFAJivmbEwf9jSPG4oq26CramqcebMi9cLls W4BOfajiwhWYg8xNpFkfx6+jMpee8DYxFrdnV/cC8g8ddl84KSw+ewQWawxPGlqLDiR8 cs5g== X-Forwarded-Encrypted: i=1; AJvYcCXChbC3LTuc1kvxxwd1Tj/efwQy1f/naoEPfW6W9Od9NaR8C4CQBy9uYYSPO0QJaViySBzLsMg6X7D5Nqf9@postgresql.org X-Gm-Message-State: AOJu0YzlSh5Z0VGI8uUm6dO9xz/91qut0yTsCWm8QXldXD7CcDixtGhV 66+koI8gRkFEP2xEzhAL70v6ylWdGzqy+lAN/HTJs01CSeKDC0EyA/M1ayKqlshP5dbie5uPZi0 FjDdhzandm5TgVNA+Bctx1+4/efRHAW4fz7BNzQLq X-Gm-Gg: ATEYQzz9NQxUe7MjVeO+kC5G5hXz9IVFjjQzJXG9dR+CoqLnFPCW2LzyHl/bsBM/Q+V WsitGtciu1uOdS3yp9meE7rlTHvL5UiLfqND3LMtHAkL9nSFvzlHypUYQBAylaSZxfFGyzRE3OL hByfKvVWiEcbPIHM9hIPz3YSArBqiEer7XSACszNC9z6LHryDK+0D758X6mkUwX8Mo7aodohu7f 5WFLy50838FrPKECeEa9ZMCQEut4lla7ozvh4mDQkessWsJGqsP214qd0LhGV2qvKfkU6D4rE3z LBHrUe54vSZAFnh4yDWiA09q3wf9lT6KQDu8+Odgfmr0npxRPZg= X-Received: by 2002:a05:620a:269a:b0:8cd:7952:d449 with SMTP id af79cd13be357-8d01c666007mr1493626685a.29.1774848142251; Sun, 29 Mar 2026 22:22:22 -0700 (PDT) MIME-Version: 1.0 References: <8437F4D0-9DFB-4045-9318-CC3C5BA2E267@paquier.xyz> In-Reply-To: <8437F4D0-9DFB-4045-9318-CC3C5BA2E267@paquier.xyz> From: Lukas Fittl Date: Sun, 29 Mar 2026 22:21:46 -0700 X-Gm-Features: AQROBzCYssAuj1tG_JJn_zviAEns5JJctvjBIebF0Ga3vxV5k1ayXt4aUoj6_Vg Message-ID: Subject: Re: Refactor query normalization into core query jumbling To: Michael Paquier Cc: Sami Imseih , zengman , pgsql-hackers , Julien Rouhaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 27, 2026 at 6:42=E2=80=AFPM Michael Paquier wrote: > > > On Mar 28, 2026, at 2:09, Sami Imseih wrote: > > I agree that ComputeConstantLengths should be in core. This one is > > not a gray area IMO. The query jumble already records constant location= s, > > but leaves the lengths unset. ComputeConstantLengths is just the > > completion of that work. There could be no other interpretation, > > unlike generate_normalized_query, of what the lengths should be. > > This is an interesting remark. One problem with any patches presented yet= is that we don=E2=80=99t attach the lengths as part of the in-core query j= umbling procedure: we plug the lengths later using the same structure as th= e query jumbling. It seems to me that this is half-baked overall. I think t= hat we don=E2=80=99t want to pay the extra length computation in the core q= uery jumbling at the end, then why does it make sense to include the length= s in the JumbleState structure at all? Shouldn=E2=80=99t we use a different= structure filled inside PGSS for this purpose rather than reuse the same t= hing for PGSS and the in-core part (don=E2=80=99t have the code in front of= me now). I see where you're coming from on that, but I don't think we can remove anything here in practice: typedef struct LocationLen { int location; /* Required */ int length; /* Set by _jumbleElements */ bool squashed; /* Set by RecordConstLocation called from _jumbleElements */ bool extern_param; /* Set by RecordConstLocation called from _jumbleParam */ } LocationLen; typedef struct JumbleState { unsigned char *jumble; /* Required */ Size jumble_len; /* Required */ LocationLen *clocations; /* Required to track constant locations */ int clocations_buf_size; /* Required to track constant locations */ int clocations_count; /* Required to track constant location= s */ int highest_extern_param_id; /* Set by _jumbleParam */ bool has_squashed_lists; /* Set by _jumbleElements */ unsigned int pending_nulls; /* Required */ Size total_jumble_len; /* Required */ } JumbleState; The only refactoring I could think of is to write out the _jumbleElements information separately, then we could actually drop length, and maybe squashed, from LocationLen. But I'm not sure that really buys us much? It would be more clear I guess, because the mixed locations of where length gets set is indeed a bit odd. I still think it'd be reasonable for us to include ComputeConstantLengths in core to complete the picture of what we're doing with _jumbleElements and the length field already anyway. Its basically a way to fully hydrate the partially filled out JumbleState from the initial jumble. Thanks, Lukas --=20 Lukas Fittl