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 1vuSQn-006H3s-15 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 09:40:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vuSQm-00CdE4-0P for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 09:40:44 +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 1vuSQl-00CdDv-2h for pgsql-hackers@lists.postgresql.org; Mon, 23 Feb 2026 09:40:43 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vuSQi-00000000qGG-46TW for pgsql-hackers@postgresql.org; Mon, 23 Feb 2026 09:40:43 +0000 Received: by mail-qt1-x842.google.com with SMTP id d75a77b69052e-503347e8715so52549761cf.2 for ; Mon, 23 Feb 2026 01:40:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771839640; cv=none; d=google.com; s=arc-20240605; b=QMwmDqaEKqFyTQPB9/TCMV3IX8JT96TpaIqqBcH4j9evvY9KQOXTWiBJBYmQb6ncEy D/C+2gTO76meObrjISvF/S1HH3/j3BzGpHmLSIFWfFPGWrCvg0vQ+kA7j9l0bqaSxCQb jk5G20l+o9+5NpyGgsn/KU8Xm8sB0Ap4qF0bIonYSUAd0PwdZYq7QMVJ6ra4DAFN1YdG A0WYzry/nZJ2ah6VNxxTSsQaX868Oaew9jaN5mQPdjXPojvyr6cQ0o2DWYpSWAtUYI78 nrq8pUAtp6mVhRZZpKjRrhzCYRwnMz3bkGbiAb6SsmC9qxfh9o2fxkhPrFjJnG0QNMPg e6BQ== 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=F8A/1rmUIjfP3DPeptbw01IRBHbpuD7uPotVkR8XLVE=; fh=q4zplcgEPnUZ6BQVnKTG1XqOMRY2cGcfndKkxPQ+j4o=; b=QxlyoyCN7WIiJGY/4/FbFx5ejzt7sjyvuGpEFGKOCtVEjAETtX64M33f22atbmYsS+ xlpxTGC+6FRpZbS1rJ21ANVIufZ8WQ4OBSDQMYIaCBN/62Nn/mxpoX8kVlwgxk9mN8CM coNQwNG272u6Xx31pgLwMN1dbqX95T4Qm524sUSGj8EcwYW98VK2kPPeqOMPOOuPM7G8 Z60wAfUFJElAV8zsnZkWMy0GbsuCSgjn76vkBwxvJ75Ec5+6/eluRpfZ/fKX0yZviCVK uwW4cnoZa20kvWoZN+ycdsb0R10cKiESjWLTLASzwUlJ9mBgxAaQdB0sYrL+ymI0BnF2 5f1w==; darn=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=20230601; t=1771839640; x=1772444440; 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=F8A/1rmUIjfP3DPeptbw01IRBHbpuD7uPotVkR8XLVE=; b=d2gmWcdlIyuSLN77YQZQSfgK0xOi9bHywl6K2vqZx0R/pRXoYEjFOHXNTC8eL1HV2f e5o0DkCjfNFj8ix3b1gyPA2YIH3xXB822lSIJXQIjGTKmWsKebl6+UMwj3bgnqlEf+Pb RR3HIM6TViN+bIlgSmx1Rv1wXLHZjSlYI8sg1+tpqJAo+2HYSthhfMfWHThYbgRwuo7N C1ORJzN4iSstjORUHk4rtBRJRdJ2aFxrjooRSVXeaRDe6lSa8oNcjT379RE+lhYc1bs9 rTWjj1oktGms+TFXRk8M2shNaTSdQGBCwfzSZPMNi3QXqZIWSgZmMaWHJuZQgpWlkoE1 30qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771839640; x=1772444440; 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=F8A/1rmUIjfP3DPeptbw01IRBHbpuD7uPotVkR8XLVE=; b=Rbr8cCjkqys2PTBLe5ivISLnlVycNczRU2yIZejh+ccO6/FcW6cs+0yZZXCkCM6YOr KvvYL/0ybx5Xc6RBSLIlrAd/OFl58aEHlmHo20i2GrFdSBhz7KPWDlEtJ8sCx5qTazjH ggzqKBFj/isD3EGbE5R1mRGG1ZhVj45V/WpgfcK7ZxcfnOYLbPhOH08QNSKt0Fwu/3s4 qai7FIo+dopD97kDdDz/XZxs/RE3N9v4tWiX43jDM7z0jlH7JzUJOWlYN8ysx/O7RaK6 beRxYGy+7cvUt8Wpgh8xb714/ydK/taYi82xCFvz+MtZwqHfXCzbMoWBZUi7Yhf4f9Ss X7jQ== X-Gm-Message-State: AOJu0YylXzy8cXRK5Z+0xuMdiw7+Uy/NWMQtlGcIIfvUpCuf/sWCBTm0 qoJX4KncAwY35S7iwbNIKQ4XFLa7ZxehdMrSGhxVUduBSHUJnCFhI7QclxQDPfqg52XjyGSCsSo cWGla0GKncBBMzq/7iB1600TN+6zZ4eM= X-Gm-Gg: AZuq6aKTu++1rKMxLLlf5+eBWyOl7q/WgFSeWmUARgNYBdf+HYUdQ8lCVulCdHenNJw LnbaILuN0ww7FM+BTbEw29fkcAL9plgjtcZNTQpNWlCB4Ete0A2z2A5HKGgMx4O2dWfWQJsBKw0 0XfISnMr9DHosZKkTwofjoyB6CUGn81xbOqEM3RKLilbEU5T10h7OUt4wlvEqjKSgOUC0RRKM7L 2z7hi0UGfVrROsK55vg0BF9g6CEG71WZQV+Z2ahLPpTGzTYXSyGc+NBJkCnBFvW6KGmQ4BKbhV1 hU10UjO8oHoxu1PIH61/1Z52b6EBGcv0v3pd+1sDZOgJ2bssKl8tirSXPKj+F0HkWkEEmI4T6eD kB1yO6UZ0WcRCUnFfSj8CntiCFas= X-Received: by 2002:a05:622a:1922:b0:4ed:1af6:230e with SMTP id d75a77b69052e-5070bca84eamr123514691cf.56.1771839640247; Mon, 23 Feb 2026 01:40:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: John Naylor Date: Mon, 23 Feb 2026 16:40:28 +0700 X-Gm-Features: AaiRm52FRHhysCltV3syRZwGDIbDI683NTADkYTyNPSEzFyyj9XT1q6hxEGjN28 Message-ID: Subject: Re: [PATCH] Refactor *_abbrev_convert() functions To: Aleksander Alekseev Cc: PostgreSQL Development 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 Tue, Feb 3, 2026 at 9:56=E2=80=AFPM Aleksander Alekseev wrote: > > There's more we can do here. Above the stanzas changed in the patch > > there is this, at least for varlena/bytea: > > > > hash =3D DatumGetUInt32(hash_any((unsigned char *) authoritative_data, > > Min(len, PG_CACHE_LINE_SIZE))); > > > > This makes no sense to me: hash_any() calls hash_bytes() and turns the > > result into a Datum, and then we just get it right back out of the > > Datum again. > > I see similar patterns in files other than bytea.c and varlena.c. > Implemented as a separate patch. I think it makes sense to squash 0001 and 0003 together, then 0002 and 0004 together. For the first, we should probably combine in the upper half when using a 64-bit hash, like this: /* Hash abbreviated key */ { - uint32 tmp; + uint64 tmp; - tmp =3D DatumGetUInt32(res) ^ (uint32) (DatumGetUInt64(res) >> 32)= ; - hash =3D DatumGetUInt32(hash_uint32(tmp)); + tmp =3D murmurhash64(DatumGetUInt64(res)); + hash =3D (uint32) tmp ^ tmp >> 32; } > Using hash_bytes_uint32() / hash_bytes_uint32_extended() directly in > timetz_hash() / timetz_hash_extended() is safe though. Proposed as a > separate patch. 0005 doesn't buy us as much in readability since the two lines no longer ma= tch. Further cleanup possible now that we have 64-bit datums: MAC addresses are always 6 bytes, so abbreviation is no longer relevant -- datum1 is authoritative. That's in scope for the thread subject but also a bigger patch, but maybe someone would like to pick it up for PG20. -- John Naylor Amazon Web Services