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 1rFbvO-00AvZO-Um for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Dec 2023 15:22:26 +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 1rFbvM-0025wS-Vx for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Dec 2023 15:22:24 +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 1rFbvM-0025wK-NS for pgsql-bugs@lists.postgresql.org; Tue, 19 Dec 2023 15:22:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFbvK-00CoZK-Fx for pgsql-bugs@lists.postgresql.org; Tue, 19 Dec 2023 15:22:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3BJFMK59036778; Tue, 19 Dec 2023 10:22:20 -0500 From: Tom Lane To: Richard Guo cc: Junwang Zhao , rekgrpth@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18247: Integer overflow leads to negative width In-reply-to: References: <18247-11ac477f02954422@postgresql.org> <2781181.1702565025@sss.pgh.pa.us> <2993260.1702654983@sss.pgh.pa.us> <4099430.1702933230@sss.pgh.pa.us> <4150261.1702958937@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Tue, 19 Dec 2023 13:53:59 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <36776.1702999340.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 19 Dec 2023 10:22:20 -0500 Message-ID: <36777.1702999340@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Tue, Dec 19, 2023 at 12:08 PM Tom Lane wrote: >> Thanks for looking! Do you have an opinion about the int64-vs-double >> question? > To be honest, I don't have a preference on which one is better. I think > double is good enough for now as we don't need to worry about overflow > with it. After sleeping on it, I'm coming around to the idea that int64 will be better. The argument that convinces me is that using int64 provides a datatype-based clue that we are working with a width and not a row count, cost, or selectivity number. I don't feel a need to go as far as invent a typedef alias like Cardinality; but plain "double" in the planner tends to be a rowcount estimate, which is not what we want people to think of. I'll make that change and push it. BTW, I think it's sufficient to fix this in HEAD. The troublesome example seems quite artificial to me, and we've not heard field reports suggesting that people have had real problems here. regards, tom lane