Looking at the function
f_jsonb_select_keys from this answer:
How to select sub-object with given keys from JSONB?
Aggregate functions that support Partial Mode are eligible to participate in various optimizations, such as parallel aggregation.
In here, jsonb_object_agg partial node is NO
In general, if a function is labeled as being safe when it is restricted or unsafe, or if it is labeled as being restricted when it is in fact unsafe, it may throw errors or produce wrong answers when used in a parallel query. C-language functions could in theory exhibit totally undefined behavior if mislabeled, since there is no way for the system to protect itself against arbitrary C code, but in most likely cases the result will be no worse than for any other function. If in doubt, it is probably best to label functions as UNSAFE.
CREATE OR REPLACE FUNCTION f_jsonb_select_keys(_js jsonb, _keys text) RETURNS jsonb LANGUAGE sql IMMUTABLE STRICT PARALLEL SAFE AS $func$ SELECT jsonb_object_agg(t.key, t.value) FROM jsonb_each(_js) t WHERE t.key = ANY (_keys); $func$;
jsonb_eachis parallel safe, but from the above excerpt from manual,
jsonb_object_aggis parallel unsafe?
- Overall, is the function