You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/04/24 00:24:00 UTC
[jira] [Comment Edited] (CALCITE-3952) Improve SortRemoveRule to
remove Sort based on rowcount
[ https://issues.apache.org/jira/browse/CALCITE-3952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17091050#comment-17091050 ]
Julian Hyde edited comment on CALCITE-3952 at 4/24/20, 12:23 AM:
-----------------------------------------------------------------
The SQL {{select * from (values 1) as t\(x) order by x fetch 1 offset 10}} should return zero rows. After you remove the Sort it will return 1 row.
I don't think we need a boolean flag and two rule instances. One rule that checks both conditions.
Yes, I think it's worth doing the RelBuilder thing as well. 3 lines in RelBuilder and a simple test in RelBuilderTest. (I know it's a bit belt-and-braces.)
was (Author: julianhyde):
The SQL {{select * from (values 1) as t(x) order by x fetch 1 offset 10}} should return zero rows. After you remove the Sort it will return 1 row.
I don't think we need a boolean flag and two rule instances. One rule that checks both conditions.
Yes, I think it's worth doing the RelBuilder thing as well. 3 lines in RelBuilder and a simple test in RelBuilderTest. (I know it's a bit belt-and-braces.)
> Improve SortRemoveRule to remove Sort based on rowcount
> -------------------------------------------------------
>
> Key: CALCITE-3952
> URL: https://issues.apache.org/jira/browse/CALCITE-3952
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Vineet Garg
> Assignee: Vineet Garg
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> If a query is guaranteed to produce maximum one row it is safe to remove Sort (along with limit).
> Example:
> {code:sql}
> select count(*) cs from store_sales where ss_ext_sales_price > 100.00 order by cs limit 100
> {code}
> Although logically equivalent this can greatly benefit physical plans by removing extra operator and avoiding unnecessary data transfer.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)