[
https://issues.apache.org/jira/browse/CALCITE-7252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zhen Chen updated CALCITE-7252:
-------------------------------
Description:
This issue implements an optimization that removes redundant columns from ORDER
BYclauses based on functional dependencies (FDs) during the SQL-to-Relational
(SQL-to-Rel) conversion process. This approach was chosen because a rule-based
implementation within the Volcano planner would face significant hurdles with
trait satisfaction. Specifically, an optimized collation (e.g., [0]) cannot
satisfy the original, broader collation requirement (e.g., [0, 1]) under the
standard trait subsumption check, which would prevent the optimizer from
selecting the more efficient plan, details see CALCITE-7234.
The implementation achieves the following results:
{code:java}
-- Original Query (FD: empno(primary key) -> sal)
select empno, sal from emp order by empno, sal;
-- Optimized Logical Plan
LogicalSort(sort0=[$0], dir0=[ASC]) <-- Instead of sort0=[$0], sort1=[$1]
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
Introduces a new optimizeOrderBy configuration parameter to enable the
optimization. The default value is false.
was:
This issue implements an optimization that removes redundant columns from ORDER
BYclauses based on functional dependencies (FDs) during the SQL-to-Relational
(SQL-to-Rel) conversion process. This approach was chosen because a rule-based
implementation within the Volcano planner would face significant hurdles with
trait satisfaction. Specifically, an optimized collation (e.g., [0]) cannot
satisfy the original, broader collation requirement (e.g., [0, 1]) under the
standard trait subsumption check, which would prevent the optimizer from
selecting the more efficient plan, details see CALCITE-7234.
The implementation achieves the following results:
{code:java}
-- Original Query (FD: empno(primary key) -> sal)
select empno, sal from emp order by empno, sal;
-- Optimized Logical Plan
LogicalSort(sort0=[$0], dir0=[ASC]) <-- Instead of sort0=[$0], sort1=[$1]
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
Introduces a new optimizeOrderBy configuration parameter to enable the
optimization. The default value is false.
> Implement ORDER BY Optimization Using Functional Dependencies at SQL-to-Rel
> Conversion Phase
> --------------------------------------------------------------------------------------------
>
> Key: CALCITE-7252
> URL: https://issues.apache.org/jira/browse/CALCITE-7252
> Project: Calcite
> Issue Type: New Feature
> Reporter: Zhen Chen
> Assignee: Zhen Chen
> Priority: Minor
>
> This issue implements an optimization that removes redundant columns from
> ORDER BYclauses based on functional dependencies (FDs) during the
> SQL-to-Relational (SQL-to-Rel) conversion process. This approach was chosen
> because a rule-based implementation within the Volcano planner would face
> significant hurdles with trait satisfaction. Specifically, an optimized
> collation (e.g., [0]) cannot satisfy the original, broader collation
> requirement (e.g., [0, 1]) under the standard trait subsumption check, which
> would prevent the optimizer from selecting the more efficient plan, details
> see CALCITE-7234.
> The implementation achieves the following results:
> {code:java}
> -- Original Query (FD: empno(primary key) -> sal)
> select empno, sal from emp order by empno, sal;
> -- Optimized Logical Plan
> LogicalSort(sort0=[$0], dir0=[ASC]) <-- Instead of sort0=[$0], sort1=[$1]
> LogicalProject(EMPNO=[$0], SAL=[$5])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
> Introduces a new optimizeOrderBy configuration parameter to enable the
> optimization. The default value is false.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)