Tom Lane:
I think you're on fairly shaky ground here. Generally speaking, a CTE
will be executed/read only when the parent query needs the next row from
it. Your examples ensure that the CTE is read before the parent query's
results are computed; but in realistic usage you'd presumably be joini
Wolfgang Walther writes:
> Now, we are wondering: To reduce overhead, can we move the set_config
> calls to a CTE as part of the main query? The values would need to be
> available with current_setting(...) in the remaining query.
I think you're on fairly shaky ground here. Generally speaking,