@@ -905,39 +905,6 @@ make_pathkeys_for_sortclauses(PlannerInfo *root,
905
905
return pathkeys ;
906
906
}
907
907
908
- /****************************************************************************
909
- * PATHKEYS AND AGGREGATES
910
- ****************************************************************************/
911
-
912
- /*
913
- * make_pathkeys_for_aggregate
914
- * Generate a pathkeys list (always a 1-item list) that represents
915
- * the sort order needed by a MIN/MAX aggregate
916
- *
917
- * This is only called before EquivalenceClass merging, so we can assume
918
- * we are not supposed to canonicalize.
919
- */
920
- List *
921
- make_pathkeys_for_aggregate (PlannerInfo * root ,
922
- Expr * aggtarget ,
923
- Oid aggsortop )
924
- {
925
- PathKey * pathkey ;
926
-
927
- /*
928
- * We arbitrarily set nulls_first to false. Actually, a MIN/MAX agg can
929
- * use either nulls ordering option, but that is dealt with elsewhere.
930
- */
931
- pathkey = make_pathkey_from_sortop (root ,
932
- aggtarget ,
933
- aggsortop ,
934
- false, /* nulls_first */
935
- 0 ,
936
- true,
937
- false);
938
- return list_make1 (pathkey );
939
- }
940
-
941
908
/****************************************************************************
942
909
* PATHKEYS AND MERGECLAUSES
943
910
****************************************************************************/
@@ -1407,11 +1374,10 @@ make_inner_pathkeys_for_merge(PlannerInfo *root,
1407
1374
* PATHKEY USEFULNESS CHECKS
1408
1375
*
1409
1376
* We only want to remember as many of the pathkeys of a path as have some
1410
- * potential use, which can include subsequent mergejoins, meeting the query's
1411
- * requested output ordering, or implementing MIN/MAX aggregates. This
1412
- * ensures that add_path() won't consider a path to have a usefully different
1413
- * ordering unless it really is useful. These routines check for usefulness
1414
- * of given pathkeys.
1377
+ * potential use, either for subsequent mergejoins or for meeting the query's
1378
+ * requested output ordering. This ensures that add_path() won't consider
1379
+ * a path to have a usefully different ordering unless it really is useful.
1380
+ * These routines check for usefulness of given pathkeys.
1415
1381
****************************************************************************/
1416
1382
1417
1383
/*
@@ -1553,50 +1519,6 @@ pathkeys_useful_for_ordering(PlannerInfo *root, List *pathkeys)
1553
1519
return 0 ; /* path ordering not useful */
1554
1520
}
1555
1521
1556
- /*
1557
- * pathkeys_useful_for_minmax
1558
- * Count the number of pathkeys that are useful for implementing
1559
- * some MIN/MAX aggregate.
1560
- *
1561
- * Like pathkeys_useful_for_ordering, this is a yes-or-no affair, but
1562
- * there could be several MIN/MAX aggregates and we can match to any one.
1563
- *
1564
- * We can't use pathkeys_contained_in() because we would like to match
1565
- * pathkeys regardless of the nulls_first setting. However, we know that
1566
- * MIN/MAX aggregates will have at most one item in their pathkeys, so it's
1567
- * not too complicated to match by brute force.
1568
- */
1569
- static int
1570
- pathkeys_useful_for_minmax (PlannerInfo * root , List * pathkeys )
1571
- {
1572
- PathKey * pathkey ;
1573
- ListCell * lc ;
1574
-
1575
- if (pathkeys == NIL )
1576
- return 0 ; /* unordered path */
1577
- pathkey = (PathKey * ) linitial (pathkeys );
1578
-
1579
- foreach (lc , root -> minmax_aggs )
1580
- {
1581
- MinMaxAggInfo * mminfo = (MinMaxAggInfo * ) lfirst (lc );
1582
- PathKey * mmpathkey ;
1583
-
1584
- /* Ignore minmax agg if its pathkey turned out to be redundant */
1585
- if (mminfo -> pathkeys == NIL )
1586
- continue ;
1587
-
1588
- Assert (list_length (mminfo -> pathkeys ) == 1 );
1589
- mmpathkey = (PathKey * ) linitial (mminfo -> pathkeys );
1590
-
1591
- if (mmpathkey -> pk_eclass == pathkey -> pk_eclass &&
1592
- mmpathkey -> pk_opfamily == pathkey -> pk_opfamily &&
1593
- mmpathkey -> pk_strategy == pathkey -> pk_strategy )
1594
- return 1 ;
1595
- }
1596
-
1597
- return 0 ; /* path ordering not useful */
1598
- }
1599
-
1600
1522
/*
1601
1523
* truncate_useless_pathkeys
1602
1524
* Shorten the given pathkey list to just the useful pathkeys.
@@ -1608,15 +1530,11 @@ truncate_useless_pathkeys(PlannerInfo *root,
1608
1530
{
1609
1531
int nuseful ;
1610
1532
int nuseful2 ;
1611
- int nuseful3 ;
1612
1533
1613
1534
nuseful = pathkeys_useful_for_merging (root , rel , pathkeys );
1614
1535
nuseful2 = pathkeys_useful_for_ordering (root , pathkeys );
1615
1536
if (nuseful2 > nuseful )
1616
1537
nuseful = nuseful2 ;
1617
- nuseful3 = pathkeys_useful_for_minmax (root , pathkeys );
1618
- if (nuseful3 > nuseful )
1619
- nuseful = nuseful3 ;
1620
1538
1621
1539
/*
1622
1540
* Note: not safe to modify input list destructively, but we can avoid
@@ -1642,8 +1560,8 @@ truncate_useless_pathkeys(PlannerInfo *root,
1642
1560
*
1643
1561
* We could make the test more complex, for example checking to see if any of
1644
1562
* the joinclauses are really mergejoinable, but that likely wouldn't win
1645
- * often enough to repay the extra cycles. Queries with no join, sort, or
1646
- * aggregate at all are reasonably common, so this much work seems worthwhile.
1563
+ * often enough to repay the extra cycles. Queries with neither a join nor
1564
+ * a sort are reasonably common, though , so this much work seems worthwhile.
1647
1565
*/
1648
1566
bool
1649
1567
has_useful_pathkeys (PlannerInfo * root , RelOptInfo * rel )
@@ -1652,7 +1570,5 @@ has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel)
1652
1570
return true; /* might be able to use pathkeys for merging */
1653
1571
if (root -> query_pathkeys != NIL )
1654
1572
return true; /* might be able to use them for ordering */
1655
- if (root -> minmax_aggs != NIL )
1656
- return true; /* might be able to use them for MIN/MAX */
1657
1573
return false; /* definitely useless */
1658
1574
}
0 commit comments