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 1sQYgE-00AO6j-7e for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jul 2024 20:40:18 +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 1sQYgB-00FI48-Un for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jul 2024 20:40:15 +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.94.2) (envelope-from ) id 1sQYgB-00FI40-LD for pgsql-hackers@lists.postgresql.org; Sun, 07 Jul 2024 20:40:15 +0000 Received: from fout7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sQYg4-000u8f-KP for pgsql-hackers@postgresql.org; Sun, 07 Jul 2024 20:40:14 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id C1EC1138050F for ; Sun, 7 Jul 2024 16:40:07 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute6.internal (MEProxy); Sun, 07 Jul 2024 16:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compiler.org; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm2; t=1720384807; x=1720471207; bh=5YMXza9wpZvtlpz7OlwtAbVWmss9NquQ E8HW9F2Cf4k=; b=IsJd4sBC65K+AL6X793kxsZsiVtsteZr/ilWRCJXicqsJ6Ho fc3O505KKgj9veMYA09XV11kkNn93MoVKymvrpoj8Uvva1wFTaGaI82TqGuwdbxv Uh0cQB/ugBuUFzPCEZ/Z48NRUVxB2y7m0zmGzeiXtlO6mwHhZ+LW9kJ5TUe0SS1q HYyj5MVQVkTMy1a/9K2onyHejT/U60JpUhv7d8V9iPovj5w1AiCD1tapEUZphowb rSSi2MB+TOuiQ0nsnZiuTvwtyMDR0qCrOBPpnQ0A3IxB+WsAT11FpkjgoXk2Y6xH Mq3sqDR5Yn1EWM7og5s6T3tbLRdInH2Xk//6og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1720384807; x=1720471207; bh=5YMXza9wpZvtlpz7OlwtAbVWmss9NquQE8H W9F2Cf4k=; b=CoJo9mYJ9FN3hG7+ffZyGJodZ9PEZ225BDiEFp10jPBUtofU0yT bb36JOkjfE4GEUpUaXXpMRLGUZzY+PNWS++a4BFF42aZL8n19FVKI+uIUSQpWLTb iHfhNFFNSSppo/cuAvHi+VqS+JGdrSkelbgjJcvO/oS0MIeQQbrlR3dGzaytQYDH /TKBbJ+TYiicmqGmaDtJ3xSYZK00+GLgO4g9FvunIvMVrs6SBUylLrS4jjVsEo+e B9SCbkJgW6bJabA9tm8yukeoikGfa7RhHQt7nE1vLG4pMLUp/OqzBTOUKlXqWr4H TnzaeRzC1MyYWtKC9+x/8m3Q+j9qxgNf4UQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdehgdduhedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehttdertd erredtnecuhfhrohhmpedflfhovghlucflrggtohgsshhonhdfuceojhhovghlsegtohhm phhilhgvrhdrohhrgheqnecuggftrfgrthhtvghrnhepudehledtheffjeekgfdujedtge ehfeeugfethffhjeejtddvjeffueekveegfeeunecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepjhhovghlsegtohhmphhilhgvrhdrohhrgh X-ME-Proxy: Feedback-ID: ic6394509:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 533F731A0065; Sun, 7 Jul 2024 16:40:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-566-g3812ddbbc-fm-20240627.001-g3812ddbb MIME-Version: 1.0 Message-Id: <041fd562-e279-4457-a118-9fda593c9be9@app.fastmail.com> Date: Sun, 07 Jul 2024 22:39:46 +0200 From: "Joel Jacobson" To: pgsql-hackers Subject: Thoughts on NBASE=100000000 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello hackers, I'm not hopeful this idea will be fruitful, but maybe we can find solutions to the problems together. The idea is to increase the numeric NBASE from 1e4 to 1e8, which could possibly give a significant performance boost of all operations across the board, on 64-bit architectures, for many inputs. Last time numeric's base was changed was back in 2003, when d72f6c75038 changed it from 10 to 10000. Back then, 32-bit architectures were still dominant, so base-10000 was clearly the best choice at this time. Today, since 64-bit architectures are dominant, NBASE=1e8 seems like it would have been the best choice, since the square of that still fits in a 64-bit signed int. Changing NBASE might seem impossible at first, due to the existing numeric data on disk, and incompatibility issues when numeric data is transferred on the wire. Here are some ideas on how to work around some of these: - Incrementally changing the data on disk, e.g. upon UPDATE/INSERT and supporting both NBASE=1e4 (16-bit) and NBASE=1e8 (32-bit) when reading data. - Due to the lack of a version field in the NumericVar struct, we need a way to detect if a Numeric value on disk uses the existing NBASE=1e4, or NBASE=1e8. One hack I've thought about is to exploit the fact that NUMERIC_NBYTES, defined as: #define NUMERIC_NBYTES(num) (VARSIZE(num) - NUMERIC_HEADER_SIZE(num)) will always be divisible by two, since a NumericDigit is an int16 (2 bytes). The idea is then to let "NUMERIC_NBYTES divisible by three" indicate NBASE=1e8, at the cost of one to three extra padding bytes. Another important aspect is disk space utilization, which is of course better for NBASE=1e4, since it packs the data more tightly. I think this is the main disadvantage of NBASE=1e8, but perhaps users would be willing to sacrifice some disk, if they would get better run-time performance. As said initially, this might be completely unrealistic, but interested to hear if anyone else have had similar dreams. Regards, Joel