Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAg9Q-0003fr-5W for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Feb 2021 21:38:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lAg9N-0000D2-SA for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Feb 2021 21:38:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAg9N-0000Cp-La for pgsql-bugs@lists.postgresql.org; Fri, 12 Feb 2021 21:38:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAg9G-0002HG-Qs for pgsql-bugs@lists.postgresql.org; Fri, 12 Feb 2021 21:38:52 +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 11CLcinO1607557; Fri, 12 Feb 2021 16:38:44 -0500 From: Tom Lane To: Alexander Lakhin cc: pgsql-bugs@lists.postgresql.org, David Rowley Subject: Re: BUG #16863: Assert failed in set_plain_rel_size() on processing ~* with a long prefix In-reply-to: <881ff073-daac-7946-cc66-c61dcfb5efa6@gmail.com> References: <16863-35bf75b1b5ee4032@postgresql.org> <6de0a0c3-ada9-cd0c-3e4e-2fa9964b41e3@gmail.com> <1578689.1613162261@sss.pgh.pa.us> <881ff073-daac-7946-cc66-c61dcfb5efa6@gmail.com> Comments: In-reply-to Alexander Lakhin message dated "Sat, 13 Feb 2021 00:00:00 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1607555.1613165924.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 12 Feb 2021 16:38:44 -0500 Message-ID: <1607556.1613165924@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Lakhin writes: > 12.02.2021 23:37, Tom Lane wrote: >> Alexander Lakhin writes: >>> I've found a division that produces NaN: >>> sel /=3D pow(FIXED_CHAR_SEL, fixed_prefix_len); >> Hmm. I'm not getting a NaN AFAICT, but I am getting pretty darn weird >> estimates. I agree this needs some kind of clamp. >> = >> regression=3D# create table test (t text); >> CREATE TABLE >> regression=3D# explain SELECT * FROM test WHERE t ~* ('^' || repeat('-'= , 500)); >> ... >> Seq Scan on test (cost=3D0.00..27.00 rows=3D10000000000000000159028911= 09759918046836080856394528138978132755774783877217038106081346998585681510= 4 width=3D32) > The same number I've seen on the master branch. But on REL_13_STABLE I > get a NaN and then the assertion failure. The difference in behavior is evidently explained by commit a90c950fc, which has decided to insert a random number in place of a NaN estimate. Well, it's not really random, it's supposed to be 1e100 ... but EXPLAIN doesn't know there's only 16 or so significant digits there. Maybe we need to work a bit harder on making that print nicely. And maybe we should rethink the idea that it's okay to gloss over a NaN estimate that way. I certainly don't see a defensible reason for assuming that NaN means "a large value". regards, tom lane