[ https://issues.apache.org/jira/browse/ASTERIXDB-2441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16581188#comment-16581188 ]
ASF subversion and git services commented on ASTERIXDB-2441: ------------------------------------------------------------ Commit 309c69c57a4fb79028eeee8efd9e179240299f3d in asterixdb's branch refs/heads/master from [~dlychagin-cb] [ https://git-wip-us.apache.org/repos/asf?p=asterixdb.git;h=309c69c ] [ASTERIXDB-2441][COMP] Improve column alias handling in ORDERBY/LIMIT - user model changes: no - storage format changes: no - interface changes: no Details: - Introduce LET clauses for column alias expressions instead of inlining them into ORDER BY/LIMIT clauses - Fix incorrect visitor used in SubstituteGroupbyExpressionWithVariableVisitor for rewriting LET clauses after GROUP BY Change-Id: If925cbb803f2ad5fe955ba343ddc62585589b894 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2905 Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <ti...@apache.org> Contrib: Till Westmann <ti...@apache.org> > 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)