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

Function get_index_paths

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

* get_index_paths * Given an index and a set of index clauses for it, construct IndexPaths. * * Plain indexpaths are sent directly to add_path, while potential * bitmap indexpaths are added to *bitindexpaths for later processing. * * This is a fairly simple frontend to build_index_paths(). Its reason for * existence is mainly to handle ScalarArrayOpExpr quals properly. If the * index A

Source from the content-addressed store, hash-verified

741 * quals so as to create ordered paths.
742 */
743static void
744get_index_paths(PlannerInfo *root, RelOptInfo *rel,
745 IndexOptInfo *index, IndexClauseSet *clauses,
746 List **bitindexpaths)
747{
748 List *indexpaths;
749 bool skip_nonnative_saop = false;
750 bool skip_lower_saop = false;
751 ListCell *lc;
752
753 /*
754 * Build simple index paths using the clauses. Allow ScalarArrayOpExpr
755 * clauses only if the index AM supports them natively, and skip any such
756 * clauses for index columns after the first (so that we produce ordered
757 * paths if possible).
758 */
759 indexpaths = build_index_paths(root, rel,
760 index, clauses,
761 index->predOK,
762 ST_ANYSCAN,
763 &skip_nonnative_saop,
764 &skip_lower_saop);
765
766 /*
767 * If we skipped any lower-order ScalarArrayOpExprs on an index with an AM
768 * that supports them, then try again including those clauses. This will
769 * produce paths with more selectivity but no ordering.
770 */
771 if (skip_lower_saop)
772 {
773 indexpaths = list_concat(indexpaths,
774 build_index_paths(root, rel,
775 index, clauses,
776 index->predOK,
777 ST_ANYSCAN,
778 &skip_nonnative_saop,
779 NULL));
780 }
781
782 /*
783 * Submit all the ones that can form plain IndexScan plans to add_path. (A
784 * plain IndexPath can represent either a plain IndexScan or an
785 * IndexOnlyScan, but for our purposes here that distinction does not
786 * matter. However, some of the indexes might support only bitmap scans,
787 * and those we mustn't submit to add_path here.)
788 *
789 * Also, pick out the ones that are usable as bitmap scans. For that, we
790 * must discard indexes that don't support bitmap scans, and we also are
791 * only interested in paths that have some selectivity; we should discard
792 * anything that was generated solely for ordering purposes.
793 */
794 foreach(lc, indexpaths)
795 {
796 IndexPath *ipath = (IndexPath *) lfirst(lc);
797
798 /*
799 * Random access to Append-Only is slow because AO doesn't use the buffer
800 * pool and we want to avoid decompressing blocks multiple times. So,

Callers 2

create_index_pathsFunction · 0.85
get_join_index_pathsFunction · 0.85

Calls 5

build_index_pathsFunction · 0.85
list_concatFunction · 0.85
add_pathFunction · 0.85
lappendFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected