Re: Better performance no-throw conversion? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Better performance no-throw conversion?
Date
Msg-id 3435889.1631122378@sss.pgh.pa.us
Whole thread Raw
In response to Better performance no-throw conversion?  ("ldh@laurent-hasson.com" <ldh@laurent-hasson.com>)
Responses Re: Better performance no-throw conversion?  (Michael Lewis <mlewis@entrata.com>)
List pgsql-performance
"ldh@laurent-hasson.com" <ldh@laurent-hasson.com> writes:
> Some databases such as SQLServer (try_cast) or BigQuery (safe.cast) offer not-throw conversion.
> ...
> I couldn't find a reference to such capabilities in Postgres and wondered if I missed it, and if not, is there any
planto 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



pgsql-performance by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Better performance no-throw conversion?
Next
From: Michael Lewis
Date:
Subject: Re: Better performance no-throw conversion?