Re: Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Wolfgang Walther
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

Re: Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Tom Lane
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,