phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "chenglei (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (PHOENIX-4618) Optimize out order-by on sort-merge-join when possible
Date Tue, 19 Mar 2019 02:01:00 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16795545#comment-16795545
] 

chenglei edited comment on PHOENIX-4618 at 3/19/19 2:00 AM:
------------------------------------------------------------

[~sangudi], yes , I think it works.
I have viewed PHOENIX-4751, seems that /* HASH_AGGREGATE */ hint only appears in {{ClientAggregatePlan}}.

Following code in {{ClientAggregatePlan.convertActualOutputOrderBy}} takes PHOENIX-4751 into
account:
{code:java}

    private OrderBy convertActualOutputOrderBy(OrderBy orderBy, GroupBy groupBy, StatementContext
statementContext) {
        if(!orderBy.isEmpty()) {
            return OrderBy.convertCompiledOrderByToOutputOrderBy(orderBy);
        }

        if(this.useHashAgg &&
           !groupBy.isEmpty() &&
           !groupBy.isOrderPreserving() &&
           orderBy != OrderBy.FWD_ROW_KEY_ORDER_BY &&
           orderBy != OrderBy.REV_ROW_KEY_ORDER_BY) {
            return OrderBy.EMPTY_ORDER_BY;
        }

        return ExpressionUtil.convertGroupByToOrderBy(groupBy, orderBy == OrderBy.REV_ROW_KEY_ORDER_BY);
    }
{code}


was (Author: comnetwork):
[~sangudi], yes , I think it works.
I have viewed PHOENIX-4751, seems that /* HASH_AGGREGATE */ hint only appears in {{ClientAggregatePlan}}.

Following code in {{ClientAggregatePlan.getOutputOrderBys}} takes PHOENIX-4751 into account:
{code:java}

    private OrderBy convertActualOutputOrderBy(OrderBy orderBy, GroupBy groupBy, StatementContext
statementContext) {
        if(!orderBy.isEmpty()) {
            return OrderBy.convertCompiledOrderByToOutputOrderBy(orderBy);
        }

        if(this.useHashAgg &&
           !groupBy.isEmpty() &&
           !groupBy.isOrderPreserving() &&
           orderBy != OrderBy.FWD_ROW_KEY_ORDER_BY &&
           orderBy != OrderBy.REV_ROW_KEY_ORDER_BY) {
            return OrderBy.EMPTY_ORDER_BY;
        }

        return ExpressionUtil.convertGroupByToOrderBy(groupBy, orderBy == OrderBy.REV_ROW_KEY_ORDER_BY);
    }
{code}

> Optimize out order-by on sort-merge-join when possible
> ------------------------------------------------------
>
>                 Key: PHOENIX-4618
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4618
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>            Priority: Major
>             Fix For: 4.15.0, 5.1.0
>
>
> To do this, \{{OrderPreservingTracker}} relies solely on primary keys for inferring alignment
between order-by expressions and the input sortedness. To implement this improvement, we
need to have extra information of sortedness which supports equivalent sorted expressions.
For example,
> {code}SELECT * FROM T1 JOIN T2 ON T1.a = T2.a and T1.b = T2.b{code}
> The result of the sort-merge-join is sorted on (T1.a, T1.b) and (T2.a, T2.b) at the same
time.
> Thus, both 1)
> {code}SELECT * FROM T1 JOIN T2 ON T1.a = T2.a and T1.b = T2.b ORDER BY T1.a, T1.b{code}
> and 2)
> {code}SELECT * FROM T1 JOIN T2 ON T1.a = T2.a and T1.b = T2.b ORDER BY T2.a, T2.b{code}
> should avoid doing an extra order-by after the sort-merge-join operation.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message