IMMUTABLE and PARALLEL SAFE function markings - Mailing list pgsql-hackers

From Gajus Kuizinas
Subject IMMUTABLE and PARALLEL SAFE function markings
Date
Msg-id CA+6d-n4dOakgLu2gsTfk9uD2CC9ueNCg+z_mnXA2-=Qaod1Wuw@mail.gmail.com
Whole thread Raw
Responses Re: IMMUTABLE and PARALLEL SAFE function markings  (Vik Fearing <vik.fearing@2ndquadrant.com>)
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: pgsql: Integrate recovery.conf into postgresql.conf
Next
From: Pavel Stehule
Date:
Subject: Re: csv format for psql