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 1mO1RZ-0002xA-E6 for pgsql-performance@arkaria.postgresql.org; Wed, 08 Sep 2021 17:33:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mO1RY-0002fO-C0 for pgsql-performance@arkaria.postgresql.org; Wed, 08 Sep 2021 17:33:04 +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 1mO1RY-0002fF-4D for pgsql-performance@lists.postgresql.org; Wed, 08 Sep 2021 17:33:04 +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 1mO1RW-0008LY-2W for pgsql-performance@postgresql.org; Wed, 08 Sep 2021 17:33:03 +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 188HWwrj3435890; Wed, 8 Sep 2021 13:32:58 -0400 From: Tom Lane To: "ldh@laurent-hasson.com" cc: "pgsql-performance@postgresql.org" Subject: Re: Better performance no-throw conversion? In-reply-to: References: Comments: In-reply-to "ldh@laurent-hasson.com" message dated "Wed, 08 Sep 2021 17:17:35 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3435888.1631122378.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Sep 2021 13:32:58 -0400 Message-ID: <3435889.1631122378@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "ldh@laurent-hasson.com" writes: > Some databases such as SQLServer (try_cast) or BigQuery (safe.cast) offe= r not-throw conversion. > ... > I couldn't find a reference to such capabilities in Postgres and wondere= d if I missed it, and if not, is there any plan to add such a feature? There is not anybody working on that AFAIK. It seems like it'd have to be done on a case-by-case basis, which makes it awfully tedious. The only way I can see to do it generically is to put a subtransaction wrapper around the cast-function call, which is a lousy idea for a couple of reasons: 1. It pretty much negates any performance benefit. 2. It'd be very hard to tell which errors are safe to ignore and which are not (e.g., internal errors shouldn't be trapped this way). Of course, point 2 also applies to user-level implementations (IOW, your code feels pretty unsafe to me). So anything we might do here would be an improvement. But it's still problematic. regards, tom lane