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

Function truncate_useless_pathkeys

src/backend/optimizer/path/pathkeys.c:2473–2496  ·  view source on GitHub ↗

* truncate_useless_pathkeys * Shorten the given pathkey list to just the useful pathkeys. */

Source from the content-addressed store, hash-verified

2471 * Shorten the given pathkey list to just the useful pathkeys.
2472 */
2473List *
2474truncate_useless_pathkeys(PlannerInfo *root,
2475 RelOptInfo *rel,
2476 List *pathkeys)
2477{
2478 int nuseful;
2479 int nuseful2;
2480
2481 nuseful = pathkeys_useful_for_merging(root, rel, pathkeys);
2482 nuseful2 = pathkeys_useful_for_ordering(root, pathkeys);
2483 if (nuseful2 > nuseful)
2484 nuseful = nuseful2;
2485
2486 /*
2487 * Note: not safe to modify input list destructively, but we can avoid
2488 * copying the list if we're not actually going to change it
2489 */
2490 if (nuseful == 0)
2491 return NIL;
2492 else if (nuseful == list_length(pathkeys))
2493 return pathkeys;
2494 else
2495 return list_truncate(list_copy(pathkeys), nuseful);
2496}
2497
2498/*
2499 * has_useful_pathkeys

Callers 2

build_index_pathsFunction · 0.85
build_join_pathkeysFunction · 0.85

Calls 5

list_lengthFunction · 0.85
list_truncateFunction · 0.85
list_copyFunction · 0.85

Tested by

no test coverage detected