* pathkeys_useful_for_ordering * Count the number of pathkeys that are useful for meeting the * query's requested output ordering. * * Because we the have the possibility of incremental sort, a prefix list of * keys is potentially useful for improving the performance of the requested * ordering. Thus we return 0, if no valuable keys are found, or the number * of leading keys shared by the
| 2450 | * of leading keys shared by the list and the requested ordering.. |
| 2451 | */ |
| 2452 | static int |
| 2453 | pathkeys_useful_for_ordering(PlannerInfo *root, List *pathkeys) |
| 2454 | { |
| 2455 | int n_common_pathkeys; |
| 2456 | |
| 2457 | if (root->query_pathkeys == NIL) |
| 2458 | return 0; /* no special ordering requested */ |
| 2459 | |
| 2460 | if (pathkeys == NIL) |
| 2461 | return 0; /* unordered path */ |
| 2462 | |
| 2463 | (void) pathkeys_count_contained_in(root->query_pathkeys, pathkeys, |
| 2464 | &n_common_pathkeys); |
| 2465 | |
| 2466 | return n_common_pathkeys; |
| 2467 | } |
| 2468 | |
| 2469 | /* |
| 2470 | * truncate_useless_pathkeys |
no test coverage detected