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

Function bring_to_singleQE

src/backend/optimizer/path/allpaths.c:596–667  ·  view source on GitHub ↗

* The following function "steals" ideas and most of the code from the * function bring_to_outer_query. * * Decorate the Paths of 'rel' with Motions to bring the relation's * result to SingleQE locus. The final plan will look something like * this: * * Result (with quals from 'outer_quals') * \ * \_Material * \ * \_ Gather *

Source from the content-addressed store, hash-verified

594 * \_SeqScan (with quals from 'baserestrictinfo')
595 */
596static void
597bring_to_singleQE(PlannerInfo *root, RelOptInfo *rel)
598{
599 List *origpathlist;
600 ListCell *lc;
601
602 origpathlist = rel->pathlist;
603 rel->cheapest_startup_path = NULL;
604 rel->cheapest_total_path = NULL;
605 rel->cheapest_unique_path = NULL;
606 rel->cheapest_parameterized_paths = NIL;
607 rel->pathlist = NIL;
608
609 foreach(lc, origpathlist)
610 {
611 Path *origpath = (Path *) lfirst(lc);
612 Path *path;
613 CdbPathLocus target_locus;
614
615 if (CdbPathLocus_IsGeneral(origpath->locus) ||
616 CdbPathLocus_IsEntry(origpath->locus) ||
617 CdbPathLocus_IsSingleQE(origpath->locus) ||
618 CdbPathLocus_IsOuterQuery(origpath->locus))
619 path = origpath;
620 else
621 {
622 /*
623 * Cannot pass a param through motion, so if this is a parameterized
624 * path, we can't use it.
625 */
626 if (origpath->param_info)
627 continue;
628
629 /*
630 * param_info cannot cover the case that an index path's orderbyclauses
631 * See github issue: https://github.com/greenplum-db/gpdb/issues/9733
632 */
633 if (IsA(origpath, IndexPath))
634 {
635 IndexPath *ipath = (IndexPath *) origpath;
636 if (contains_outer_params((Node *) ipath->indexorderbys,
637 (void *) root))
638 continue;
639 }
640
641 CdbPathLocus_MakeSingleQE(&target_locus,
642 origpath->locus.numsegments);
643
644 path = cdbpath_create_motion_path(root,
645 origpath,
646 NIL, // DESTROY pathkeys
647 false,
648 target_locus);
649
650 path = (Path *) create_material_path(rel, path);
651 }
652
653 add_path(rel, path, root);

Callers 1

set_rel_pathlistFunction · 0.85

Calls 6

contains_outer_paramsFunction · 0.85
create_material_pathFunction · 0.85
add_pathFunction · 0.85
set_cheapestFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected