Bonnie Varghese created FLINK-41636:
---------------------------------------

             Summary: Remove duplicates from the right input of 
INTERSECT/EXCEPT in batch mode
                 Key: FLINK-41636
                 URL: https://issues.apache.org/jira/browse/FLINK-41636
             Project: Flink
          Issue Type: Improvement
          Components: Table SQL / Planner
    Affects Versions: 2.5.0
            Reporter: Bonnie Varghese
            Assignee: Bonnie Varghese
             Fix For: 2.5.0


In batch mode, a distinct INTERSECT/EXCEPT is rewritten to a SEMI/ANTI join on 
all columns. The right input goes into the join unchanged, but the join only 
checks whether a match exists, so duplicates on the right are wasted work. They 
also inflate the right input's row count, which can cause the planner can pick 
the wrong build side.

Observed while testing TPC-DS SF100 q14a/q14b
The right input of the INTERSECT repeats a few thousand item keys tens of 
millions of times. The planner builds the hash table on the small left input 
and probes it with every right row.

Adding a distinct helps improve the query runtime by 6-7x



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to