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

Function get_join_index_paths

src/backend/optimizer/path/indxpath.c:612–683  ·  view source on GitHub ↗

* get_join_index_paths * Generate index paths using clauses from the specified outer relations. * In addition to generating paths, relids is added to *considered_relids * if not already present. * * Workhorse for consider_index_join_clauses; see notes therein for rationale. * * 'rel', 'index', 'rclauseset', 'jclauseset', 'eclauseset', * 'bitindexpaths', 'considered_relids' as above

Source from the content-addressed store, hash-verified

610 * one or more outer rels)
611 */
612static void
613get_join_index_paths(PlannerInfo *root, RelOptInfo *rel,
614 IndexOptInfo *index,
615 IndexClauseSet *rclauseset,
616 IndexClauseSet *jclauseset,
617 IndexClauseSet *eclauseset,
618 List **bitindexpaths,
619 Relids relids,
620 List **considered_relids)
621{
622 IndexClauseSet clauseset;
623 int indexcol;
624
625 /* If we already considered this relids set, don't repeat the work */
626 if (bms_equal_any(relids, *considered_relids))
627 return;
628
629 /* Identify indexclauses usable with this relids set */
630 MemSet(&clauseset, 0, sizeof(clauseset));
631
632 for (indexcol = 0; indexcol < index->nkeycolumns; indexcol++)
633 {
634 ListCell *lc;
635
636 /* First find applicable simple join clauses */
637 foreach(lc, jclauseset->indexclauses[indexcol])
638 {
639 IndexClause *iclause = (IndexClause *) lfirst(lc);
640
641 if (bms_is_subset(iclause->rinfo->clause_relids, relids))
642 clauseset.indexclauses[indexcol] =
643 lappend(clauseset.indexclauses[indexcol], iclause);
644 }
645
646 /*
647 * Add applicable eclass join clauses. The clauses generated for each
648 * column are redundant (cf generate_implied_equalities_for_column),
649 * so we need at most one. This is the only exception to the general
650 * rule of using all available index clauses.
651 */
652 foreach(lc, eclauseset->indexclauses[indexcol])
653 {
654 IndexClause *iclause = (IndexClause *) lfirst(lc);
655
656 if (bms_is_subset(iclause->rinfo->clause_relids, relids))
657 {
658 clauseset.indexclauses[indexcol] =
659 lappend(clauseset.indexclauses[indexcol], iclause);
660 break;
661 }
662 }
663
664 /* Add restriction clauses */
665 clauseset.indexclauses[indexcol] =
666 list_concat(clauseset.indexclauses[indexcol],
667 rclauseset->indexclauses[indexcol]);
668
669 if (clauseset.indexclauses[indexcol] != NIL)

Callers 1

Calls 6

bms_equal_anyFunction · 0.85
bms_is_subsetFunction · 0.85
lappendFunction · 0.85
list_concatFunction · 0.85
get_index_pathsFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected