MCPcopy Create free account
hub / github.com/apache/cloudberry / find_join_rel

Function find_join_rel

src/backend/optimizer/util/relnode.c:573–617  ·  view source on GitHub ↗

* find_join_rel * Returns relation entry corresponding to 'relids' (a set of RT indexes), * or NULL if none exists. This is for join relations. */

Source from the content-addressed store, hash-verified

571 * or NULL if none exists. This is for join relations.
572 */
573RelOptInfo *
574find_join_rel(PlannerInfo *root, Relids relids)
575{
576 /*
577 * Switch to using hash lookup when list grows "too long". The threshold
578 * is arbitrary and is known only here.
579 */
580 if (!root->join_rel_hash && list_length(root->join_rel_list) > 32)
581 build_join_rel_hash(root);
582
583 /*
584 * Use either hashtable lookup or linear search, as appropriate.
585 *
586 * Note: the seemingly redundant hashkey variable is used to avoid taking
587 * the address of relids; unless the compiler is exceedingly smart, doing
588 * so would force relids out of a register and thus probably slow down the
589 * list-search case.
590 */
591 if (root->join_rel_hash)
592 {
593 Relids hashkey = relids;
594 JoinHashEntry *hentry;
595
596 hentry = (JoinHashEntry *) hash_search(root->join_rel_hash,
597 &hashkey,
598 HASH_FIND,
599 NULL);
600 if (hentry)
601 return hentry->join_rel;
602 }
603 else
604 {
605 ListCell *l;
606
607 foreach(l, root->join_rel_list)
608 {
609 RelOptInfo *rel = (RelOptInfo *) lfirst(l);
610
611 if (bms_equal(rel->relids, relids))
612 return rel;
613 }
614 }
615
616 return NULL;
617}
618
619/*
620 * set_foreign_rel_properties

Callers 6

postgresPlanDirectModifyFunction · 0.85
examine_variableFunction · 0.85
find_join_input_relFunction · 0.85
get_matching_part_pairsFunction · 0.85
build_join_relFunction · 0.85
build_child_join_relFunction · 0.85

Calls 5

list_lengthFunction · 0.85
build_join_rel_hashFunction · 0.85
hash_searchFunction · 0.85
bms_equalFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected