[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Description: When a Sort represents 'Order By x Limit n',and its input is guaranteed that is at most one row,we could remove this Sort. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: This JIRA is enhancement for {-}CALCITE-5994{-}, in -CALCITE-5994- ,we restrict Sort must be pure Order(Offset and Limit is null),after this jira,this optimization could be applied to 'Order By x' Or 'Order By x Limit n'. was: When a Sort represents 'Order By x Limit n',and its input is guaranteed that is at most one row,we could remove this Sort. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: > Remove 'Order By x Limit n' when the input is guaranteed that is at most one > row > - > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > When a Sort represents 'Order By x Limit n',and its input is guaranteed that > is at most one row,we could remove this Sort. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > This JIRA is enhancement for {-}CALCITE-5994{-}, in -CALCITE-5994- ,we > restrict Sort must be pure Order(Offset and Limit is null),after this > jira,this optimization could be applied to 'Order By x' Or 'Order By x Limit > n'. > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Description: When a Sort represents 'Order By x Limit n',and its input is guaranteed that is at most one row,we could remove this Sort. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: was: When a Sort represents 'Order By x Limit n',and its input source row count is provably at most one row,then we could remove the redundant TopN. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: > Remove 'Order By x Limit n' when the input is guaranteed that is at most one > row > - > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > When a Sort represents 'Order By x Limit n',and its input is guaranteed that > is at most one row,we could remove this Sort. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Summary: Remove 'Order By x Limit n' when the input is guaranteed that is at most one row (was: Remove 'Order By x Limit n'' when the input is guaranteed that is at most one row) > Remove 'Order By x Limit n' when the input is guaranteed that is at most one > row > - > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > When a Sort is ''TopN's input source row count is provably at most one > row,then we could remove the redundant TopN. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Description: When a Sort represents 'Order By x Limit n',and its input source row count is provably at most one row,then we could remove the redundant TopN. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: was: When a Sort is ''TopN's input source row count is provably at most one row,then we could remove the redundant TopN. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: > Remove 'Order By x Limit n' when the input is guaranteed that is at most one > row > - > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > When a Sort represents 'Order By x Limit n',and its input source row count is > provably at most one row,then we could remove the redundant TopN. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n'' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Description: When a Sort is ''TopN's input source row count is provably at most one row,then we could remove the redundant TopN. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: was: In Calcite , the TopN is represented by `Sort`,when a TopN's input source row count is provably at most one row ,then we could remove the redundant TopN. For example,the sql: {code:java} SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} because the `SELECT count(*) FROM orders ` row count is 1, it is at most one row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the sql is : {code:java} SELECT count(*) FROM orders {code} Above logic are same as Presto/Trino's [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] rule: > Remove 'Order By x Limit n'' when the input is guaranteed that is at most > one row > -- > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > When a Sort is ''TopN's input source row count is provably at most one > row,then we could remove the redundant TopN. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6038) Remove 'Order By x Limit n'' when the input is guaranteed that is at most one row
[ https://issues.apache.org/jira/browse/CALCITE-6038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] LakeShen updated CALCITE-6038: -- Summary: Remove 'Order By x Limit n'' when the input is guaranteed that is at most one row (was: Remove 'Limit n' when the input is guaranteed to never return more than 'n' rows) > Remove 'Order By x Limit n'' when the input is guaranteed that is at most > one row > -- > > Key: CALCITE-6038 > URL: https://issues.apache.org/jira/browse/CALCITE-6038 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: LakeShen >Assignee: LakeShen >Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > In Calcite , the TopN is represented by `Sort`,when a TopN's input source row > count is provably at most one row > ,then we could remove the redundant TopN. > For example,the sql: > {code:java} > SELECT count(*) FROM orders ORDER BY 1 LIMIT 10 {code} > because the `SELECT count(*) FROM orders ` row count is 1, it is at most one > row,then we could remove `ORDER BY 1 LIMIT 10 `,after the optimization,the > sql is : > {code:java} > SELECT count(*) FROM orders {code} > Above logic are same as Presto/Trino's > [RemoveRedundantTopN|https://github.com/prestodb/presto/blob/21ab1ea2425e4bc65532ab156c60333e5a72dd09/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantTopN.java#L27C1-L28C34] > rule: > -- This message was sent by Atlassian Jira (v8.20.10#820010)