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 1tqgUB-008psx-TI for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 22:48:07 +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 1tqgU8-001RDN-45 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 22:48:04 +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.94.2) (envelope-from ) id 1tqgU7-001RDF-PZ for pgsql-hackers@lists.postgresql.org; Fri, 07 Mar 2025 22:48:03 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tqgU3-001a7f-3C for pgsql-hackers@postgresql.org; Fri, 07 Mar 2025 22:48:03 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-30795988ebeso24109301fa.3 for ; Fri, 07 Mar 2025 14:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741387680; x=1741992480; 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=urDPBwFryLdD0TmnCsA0QAPGqgOEYXH7jqZooEKcziQ=; b=noOhb6VqOf/c/7ld1YjLR5grnmofBmmAwB5UTLVwGJ1ocSV3NGQEwhJRQEuz/qvywt tbXsUKPP9XDc67+ahR5l/EnvTnqMOjDeVzeQ4mmWCNOcOmlUqBodB1tKNSBRaPUoRbj0 Y8H0BK1k0a93zZfWHTKQIJDhcu38BN2XzFqOc4rbLiUqwhZCiIRW96Nb5qXwRDnsGXYr 9WGgGZfLFTt+WCdgeCyFWCaZfwO9gNdeI+BsptUjJQzx61fJbWk6Dxfxza3YO8Ix/yYe /Di2cnXdSzT5Pa3bZIIMD0v572XVUCgE3/MxEWfXflYtILqQgTKJfVt7jqnNPM+iisK2 yZaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741387680; x=1741992480; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=urDPBwFryLdD0TmnCsA0QAPGqgOEYXH7jqZooEKcziQ=; b=NTMgLKqh5FTGca9ZZZiaIAhl2v5mnZHULcdShYzcMrj3bCgIZoxRmSI1VeBVizyxrc Rp2ux68E2e/CYpBp87PhwWl/E4jC7Kp7l7Z3Nqr6+B8D4bOzVBA+mVpEs3fO7ww9wsHO BT5p6eH+SnfyfePQQMyCTsRG0/0fUAbnp+I9tXR1pABiQ0uD5RWTITXgPmSMp9et7WCY 5Ve5nRdP5vjcPw2mj69Oi5JIVcRV7SGE9i8C/I86M85eDgjd8Ow98aKPaWcKgisAk7/H beu0osDNjQ5PqC1Ouk6BvS7IHx9v/0YO2xMAtVyD7J7qQMe1Sh1JsN1VhwgqpHftEZSr rKtQ== X-Gm-Message-State: AOJu0YxoMblD20FWbQE4VKA860fqZJCisdfr/Ivv3YBcXngcs/FEhEQA 9lsRryD5zsFpcL5FraQZPRablf4bVTcrShCZnJ9mF/5cxp7YspxxouIS+j9Us136MHAElOoPOQF iWR6LVCmGHDAhzbVYboD+noNUjWLtwOhI X-Gm-Gg: ASbGncuaM3pupdRkktPjwvfaAZPlS7qRxjK70chkTyGlqvzjYyMPd8ot2Uh+mb11kj1 Wuj/IKkBD4RMt/nNa+f98YpAoxRDXXs1Vg8xXaP/qGErrLpNrZ7w81sXCVEWoKt0K0BQb5kkvC+ y0MZreEJLaC2dJZZMO1WSoqJvD8g== X-Google-Smtp-Source: AGHT+IFDmWb33KbTAxzDSg1ykR1j+KoypHT6b6WL0+VEKGOMBkbocCQONF7FGoMaI/W9Gz/iy2eCSRQIPCFNjCbW2A8= X-Received: by 2002:a2e:b887:0:b0:30b:edfc:5d8a with SMTP id 38308e7fff4ca-30bf43b9bdamr16965451fa.0.1741387679714; Fri, 07 Mar 2025 14:47:59 -0800 (PST) MIME-Version: 1.0 References: <78574B24-BE0A-42C5-8075-3FA9FA63B8FC@amazon.com> <238EEE41-B206-4590-8C20-DA52C25A2291@amazon.com> <51C77060-059F-4BB3-8EAF-83F08656F6D2@amazon.com> In-Reply-To: From: Matthias van de Meent Date: Fri, 7 Mar 2025 23:47:45 +0100 X-Gm-Features: AQ5f1JoLFeLX877cuJ6hrRk78U16YkX1d-AOHOCweQ7Eq0lBzs6NgndErKjEM9w Message-ID: Subject: Re: Expanding HOT updates for expression and partial indexes To: "Burd, Greg" Cc: "pgsql-hackers@postgresql.org" 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 Thu, 6 Mar 2025 at 13:40, Burd, Greg wrote: > > > On Mar 5, 2025, at 6:39=E2=80=AFPM, Matthias van de Meent wrote: > > > > On Wed, 5 Mar 2025 at 18:21, Burd, Greg wrote: > >> * augments IndexInfo only when needed for testing expressions and only= once > > > > ExecExpressionIndexesUpdated seems to always loop over all indexes, > > always calling AttributeIndexInfo which always updates the fields in > > the IndexInfo when the index has only !byval attributes (e.g. text, > > json, or other such varlena types). You say it happens only once, have > > I missed something? > > There's a test that avoids doing it more than once, [...] Is this that one? + if (indexInfo->ii_IndexAttrByVal) + return indexInfo; I think that test doesn't work consistently: a bitmapset * is NULL when no bits are set; and for some indexes no attribute will be byval, thus failing this early-exit even after processing. Another small issue with this approach is that it always calls and tests in EEIU(), while it's quite likely we would do better if we pre-processed _all_ indexes at once, so that we can have a path that doesn't repeatedly get into EEIU only to exit immediately after. It'll probably be hot enough to not matter much, but it's still cycles spent on something that we can optimize for in code. > >> * retains existing summarized index HOT update logic > > > > Great, thanks! > > > > Kind regards, > > > > Matthias van de Meent > > Neon (https://neon.tech) > > I might widen this patch a bit to include support for testing equality of= index tuples using custom operators when they exist for the index. In the= use case I'm solving for we use a custom operator for equality that is not= the same as a memcmp(). Do you have thoughts on that? I don't think that's a very great idea. From a certain point of view, you can see HOT as "deduplicating multiple tuple versions behind a single TID". Btree doesn't support deduplication for types that can have more than one representation of the same value so that e.g. '0.0'::numeric and '0'::numeric are both displayed correctly, even when they compare as equal according to certain equality operators. So, I don't think that's worth investing time into right now. Maybe in the future if there are new discoveries about what we can and cannot deduplicate, but I don't think it should be part of an MVP or 1.0. Kind regards, Matthias van de Meent