[
https://issues.apache.org/jira/browse/ASTERIXDB-2441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dmitry Lychagin resolved ASTERIXDB-2441.
----------------------------------------
Resolution: Fixed
> Change how column aliases are inlined into order by and limit clauses
> ----------------------------------------------------------------------
>
> Key: ASTERIXDB-2441
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-2441
> Project: Apache AsterixDB
> Issue Type: Improvement
> Reporter: Dmitry Lychagin
> Assignee: Dmitry Lychagin
> Priority: Minor
>
> Currently when a column alias is referenced by an ORDER BY or a LIMIT clause
> we copy the column alias expression into that clause during query rewriting (
> SqlppQueryRewriter.inlineColumnAlias()). This may lead to suboptimal query
> plans when the copied expression is complex and cannot be factored out by the
> optimizer's ExtractCommonExpressionsRule (for example AGGREGATE_FN(DISTINCT
> ...). In those cases the expression will be executed twice an runtime.
> A better approach is to introduce a variable for that expression (LET clause)
> and refer to that variable from SELECT and ORDER BY/LIMIT clauses. This way
> the optimizer can decide whether this LET clause should be inlined or not.
> For example.
> SELECT f(x) AS y FROM ... ORDER BY y
> Is currently rewritten into
> SELECT f(x) AS y FROM ... ORDER BY f(x)
> With the new approach it will be rewritten into
> SELECT z AS y FROM ... LET z = f(x) ORDER BY z
>
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)