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 1ralCg-00BKN3-FG for pgsql-general@arkaria.postgresql.org; Thu, 15 Feb 2024 23:31:42 +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 1ralCe-00FuNl-Gs for pgsql-general@arkaria.postgresql.org; Thu, 15 Feb 2024 23:31:40 +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 1ralCe-00FuNc-6C for pgsql-general@lists.postgresql.org; Thu, 15 Feb 2024 23:31:40 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ralCY-006xHe-2u for pgsql-general@lists.postgresql.org; Thu, 15 Feb 2024 23:31:38 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 79E4B18218; Fri, 16 Feb 2024 00:31:30 +0100 (CET) Date: Fri, 16 Feb 2024 00:31:30 +0100 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: How to do faster DML Message-ID: <20240215233130.mutkz2rcjehhtixg@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <20240211133203.zw6ezhdzefyxmkd7@hjp.at> <20240211222230.tt3mpjdvgrimeodu@hjp.at> <20240213150234.ydiitfoowojhj2n3@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jwg625tt3rac4xxo" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --jwg625tt3rac4xxo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2024-02-14 22:55:01 -0700, David G. Johnston wrote: > On Tuesday, February 13, 2024, veem v wrote: >=20 > float data types rather than numeric. This will give better performan= ce. >=20 >=20 > =C2=A0Only use an inexact floating-point data type if you truly understan= d what you > are getting yourself into.=C2=A0 Quickly getting the wrong answer isn=E2= =80=99t tolerable > solution. Do NOT assume that a decimal type (even if it can grow to ridiculuous lengths like PostgreSQL's numeric) is exact in the mathematical sense. It isn't. It cannot represent almost all real numbers. No pi or e of course, but also no seemingly simple fractions like 1/3 or 1/7. Unless you never divide anything, you will need to be aware of the rounding behaviour, just as you have to with binary floating point types. And if you use a finite precision you will also have to deal with rounding on multiplication (and possibly even addition and subtraction, if you use different precisions). Almost 40 years ago, our numerical methods professor started his first lecture with the sentence "You can use a computer for anything - except computing". He spent the rest of the semester proving himself wrong, of course, but computing correctly is hard - and choosing a data type which more closely mimics the way we learn to compute in primary school doesn't necessarily make it easier. Mostly it just makes it harder to spot the errors ;-). hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --jwg625tt3rac4xxo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmXOns4ACgkQ8g5IURL+ KF1o1Q/+KMabgXbI+eQtgWjmcAZExfFvBkd+5VvgJchCHSecwWA/z0JJql9XrZul 2yVkXq2CZ8ilU4vWd0BXLN8/JgvdLkVX7zw+fzjhQAX1GfFZZVAl+mPrQ2MzuFjb flQYb4W+Y9U+wWwUA++vHUcMYCmOVPKf3z7ebHeh8DeWyrddtccG2+C3piNjXHkR xTpezOrKf5cOW5EHZpT4uxc0rtcoRLcJrzhMFvHsrC438kaka/vICDtZ9evOQwom Z3ma06JADtMpDBJbZILNF2dJEI4K/FxqA+9Gge+3//f4zZQRxHKCvac6aM6rf0T2 1ycDmuwx55ydmqPTH4bGG1alJ3h79DGKycyyxKJoySNci8vE8km5dQ5XOw6sO8IY 0tOa85d2t93+g5Q2GbsHp+imYAISBZ5Yf44ABH+gw7RowGwC2BjWQHqQ2p4fyCrq VxIEnNraulXtAFnUa3pGAQRPb3EGuydUKjZkfS0zqZnsWR2VOMt7RieWAEltVhdJ kFItvpWpC6kpbDqIprGDVsyc6Zcpm1bgUIb6kU0O0ygXVEmKU6gY+XIWqVZ/5/fJ bBa7dygFOV+E225L/C3C5fWUnDGNKdoD9FXtNCgkAnOrRN8RPmJSs0L6G4MgNRyM OeyfsgOwc1QqD3AsNfSkooyEtI/8NuH7BVZGFWFtpVJtAGfbWAw= =e8gP -----END PGP SIGNATURE----- --jwg625tt3rac4xxo--