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_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9e40d07e140bc21186a8bdd1cb8b35d4d5f65979 Modified Files -------------- src/backend/optimizer/prep/prepjointree.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
