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 1nj40A-0008K3-Nu for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2022 19:04:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nj409-00027A-Fn for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2022 19:04:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nj409-000271-7l for pgsql-bugs@lists.postgresql.org; Mon, 25 Apr 2022 19:04:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nj406-0003K1-SX for pgsql-bugs@lists.postgresql.org; Mon, 25 Apr 2022 19:04:00 +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 23PJ3WVr116337; Mon, 25 Apr 2022 15:03:32 -0400 From: Tom Lane To: Federico Travaglini cc: pgsql-bugs@lists.postgresql.org Subject: Re: 14.1 immutable function, bad performance if check number = 'NaN' In-reply-to: References: Comments: In-reply-to Federico Travaglini message dated "Mon, 25 Apr 2022 16:57:41 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <116335.1650913412.1@sss.pgh.pa.us> Date: Mon, 25 Apr 2022 15:03:32 -0400 Message-ID: <116336.1650913412@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Federico Travaglini writes: > This funcion in used as a column in a select on about 400k records > If I leave the highlighted row it takes 27 seconds, otherwise 14 seconds! > Such behaviour looks not to be reasonable. It's not at all clear which line you think is the "highlighted" one. However, I'm guessing that this SQL function is a candidate for inlining, so you might try comparing EXPLAIN VERBOSE output for the query with both forms of the function. Perhaps that will yield some insight into what's expensive. regards, tom lane