pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: ldh@laurent-hasson.com <ldh@laurent-hasson.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Better performance no-throw conversion?
Date: Wed, 08 Sep 2021 13:32:58 -0400
Message-ID: <3435889.1631122378@sss.pgh.pa.us> (raw)
In-Reply-To: <MN2PR15MB2560C23261EFFBFC9F437A5B85D49@MN2PR15MB2560.namprd15.prod.outlook.com>
References: <MN2PR15MB2560C23261EFFBFC9F437A5B85D49@MN2PR15MB2560.namprd15.prod.outlook.com>

"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 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





view thread (6+ messages)  latest in thread

Message-ID: <3435889.1631122378@sss.pgh.pa.us>
Permalink:  ../3435889.1631122378@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3435889.1631122378@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ldh@laurent-hasson.com
  Subject: Re: Better performance no-throw conversion?
  In-Reply-To: <3435889.1631122378@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox