Re: IMMUTABLE and PARALLEL SAFE function markings

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, gajus(at)gajus(dot)com, "pgsql-hackers\(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: IMMUTABLE and PARALLEL SAFE function markings
Date: 2018-11-27 04:31:19
Message-ID: 87tvk3no71.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

Tom> Hm. We intentionally allow SQL functions to be marked as less
Tom> mutable than their internals, because sometimes that's useful for
Tom> tricking the planner. However, IIRC we don't inline when we see
Tom> that's the case. Maybe there needs to be a similar restriction for
Tom> parallelism markings.

Well, that doesn't help since not inlining the function doesn't prevent
it from being called in parallel mode.

On second thoughts the problem actually isn't directly to do with
inlining at all. The problem is that in the presence of polymorphism,
the function author can't have any confidence in setting any function as
parallel-safe, since they can't know what the actual functions are that
will be called at run time.

The _nice_ fix for this would be to make it ok to leave inlinable
functions as parallel-unsafe, and have the inlined version checked for
parallel safety. Which would require doing...

Tom> Alternatively, could we postpone the parallelism checks till after
Tom> function inlining? Do we even make any before that?

Right now, the parallelism checks are pretty much the very first thing
done on the query, right at the start of standard_planner.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-11-27 04:31:52 Re: IMMUTABLE and PARALLEL SAFE function markings
Previous Message Robert Haas 2018-11-27 04:26:32 Re: IMMUTABLE and PARALLEL SAFE function markings