I have defined a function "is_not_distinct" for the purpose of creating a
custom operator "===".

CREATE FUNCTION is_not_distinct(a anyelement, b anyelement)
returns boolean
language sql as $$
  select a is not distinct from b;
$$
IMMUTABLE;

CREATE OPERATOR === (
  LEFTARG = anyelement,
  RIGHTARG = anyelement,
  PROCEDURE = is_not_distinct,
  NEGATOR = !==
);

I have observed that the resulting queries were executed without using
parallelisation.

I have learned by asking on Freenode that the reason my queries are not
using parallelisation is because I have not configured PARALLEL SAFE.

I find it counter-intuitive that a function with IMMUTABLE marking would
require an explicit PARALLEL SAFE. It would seem logical that in all cases
where a function is appropriately market as IMMUTABLE it would also
be PARALLEL SAFE.

I was wondering what is the reason IMMUTABLE functions are not by
default PARALLEL SAFE and if the default behaviour could be changed to make
IMMUTABLE functions PARALLEL SAFE?

Thank you,

Gajus
ᐧ

Reply via email to