Skip unnecessary get_relids_in_jointree() when there are no PHVs

Commit 1df9e8d96 made remove_useless_result_rtes() compute the set of
baserels in the jointree, to pass down to the find_dependent_phvs()
checks.  But those checks are no-ops when the query contains no PHVs,
since find_dependent_phvs() and find_dependent_phvs_in_jointree() both
return early in that case.  So we can avoid the
get_relids_in_jointree() scan altogether when root->glob->lastPHId is
zero, leaving baserels as NULL.

Author: Richard Guo <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: 
https://postgr.es/m/cambws49h275kzgzr3cd1hy+6lmwp35bz+5prvc62k3hdlj6...@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d610d8e8be5678f828e07aa99c16c1dcc2e4ef63

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

Reply via email to