[ 
https://issues.apache.org/jira/browse/CALCITE-4633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17357580#comment-17357580
 ] 

Sean Broeder commented on CALCITE-4633:
---------------------------------------

I think this query  demonstrates an opportunity for improvement:

select count ("customer_id") from
    (select "sales1"."customer_id", "sales1"."store_id", "sales1"."unit_sales", 
"store1"."store_name"
        from "sales_fact_1997" as "sales1"
    inner join "store" as "store1" on "sales1"."store_id" = "store1"."store_id"
    union
    select "sales2"."customer_id", "sales2"."store_id", "sales2"."unit_sales", 
"store2"."store_name"
        from "sales_fact_1998" as "sales2"
    inner join "store" as "store2" on "sales2"."store_id" = "store2"."store_id")

The inputs for the union are joins and below the joins we do a complete table 
scan without trimming.  With the change I am proposing there would be a project 
between the table scan and the join, which should improve performance.

Please let me know your thoughts and if you agree it is worth review I will 
push a PR for evaluation.

> Enable RelFieldTrimmer to trim fields on a distinct UNION
> ---------------------------------------------------------
>
>                 Key: CALCITE-4633
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4633
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: Sean Broeder
>            Assignee: Sean Broeder
>            Priority: Major
>             Fix For: 1.28.0
>
>
> Should be able to push a project to trim fields on top of distinct union 
> without changing results.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to