<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Impala hash join optimization in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-hash-join-optimization/m-p/80579#M83993</link>
    <description>&lt;P&gt;Hi Cloudera Impala community,&lt;/P&gt;
&lt;P&gt;we have many join queries between Impala (HDFS) and Kudu datasets where the large kudu table is joined with a small HDFS table. I see in many cases, that the HDFS dataset condition returns 0 rows, but the query still scans all the 600mil records in Kudu.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example this query is running for 10min+ and it is clear that the right part of the query, the broadcasted dataset is empty, zero rows. So the optimizer could just skip the scanning and return empty dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Query plan&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="join_with_zero_table.PNG" style="width: 600px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/4883iCD1BA9EBAA17AF40/image-size/large?v=v2&amp;amp;px=999" role="button" title="join_with_zero_table.PNG" alt="join_with_zero_table.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;Max Per-Host Resource Reservation: Memory=17.00MB
Per-Host Resource Estimates: Memory=193.00MB

F02:PLAN FRAGMENT [UNPARTITIONED] hosts=1 instances=1
|  Per-Host Resources: mem-estimate=0B mem-reservation=0B
PLAN-ROOT SINK
|  mem-estimate=0B mem-reservation=0B
|
04:EXCHANGE [UNPARTITIONED]
|  mem-estimate=0B mem-reservation=0B
|  tuple-ids=0,1 row-size=1.62KB cardinality=88114
|
F00:PLAN FRAGMENT [RANDOM] hosts=9 instances=9
Per-Host Resources: mem-estimate=17.00MB mem-reservation=17.00MB
02:HASH JOIN [INNER JOIN, BROADCAST]
|  hash predicates: tab.key1 = pk.key1, tab.key2 = pk.key2, tab.key3 = pk.key3, tab.key4 = pk.key4, tab.root_key3 = pk.root_key3
|  fk/pk conjuncts: tab.key1 = pk.key1, tab.key2 = pk.key2, tab.key3 = pk.key3, tab.key4 = pk.key4, tab.root_key3 = pk.root_key3
|  mem-estimate=17.00MB mem-reservation=17.00MB spill-buffer=1.00MB
|  tuple-ids=0,1 row-size=1.62KB cardinality=88114
|
|--03:EXCHANGE [BROADCAST]
|  |  mem-estimate=0B mem-reservation=0B
|  |  tuple-ids=1 row-size=159B cardinality=88114
|  |
|  F01:PLAN FRAGMENT [RANDOM] hosts=1 instances=1
|  Per-Host Resources: mem-estimate=176.00MB mem-reservation=0B
|  01:SCAN HDFS [work.pk_table_pk pk, RANDOM]
|     partitions=1/1 files=1 size=2.51MB
|     predicates: pk.rn = 1, pk.tr_code IN ('D')
|     stats-rows=249225 extrapolated-rows=disabled
|     table stats: rows=249225 size=2.51MB
|     column stats: all
|     parquet statistics predicates: pk.rn = 1, pk.tr_code IN ('D')
|     parquet dictionary predicates: pk.rn = 1, pk.tr_code IN ('D')
|     mem-estimate=176.00MB mem-reservation=0B
|     tuple-ids=1 row-size=159B cardinality=88114
|
00:SCAN KUDU [base.large_table tab]
   mem-estimate=0B mem-reservation=0B
   tuple-ids=0 row-size=1.46KB cardinality=674357713&lt;/PRE&gt;
&lt;P&gt;The query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;select *
from base.large_table tab join 
work.pk_table_pk pk ON 
         tab.`key1` = pk.`key1` and 
     tab.`key2` = pk.`key2` and 
     tab.`key3` = pk.`key3` and 
     tab.`key4` = pk.`key4` and 
     tab.`root_key3` = pk.`root_key3` 
where pk.tr_code in ('D') and pk.rn =1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is running on CDH 5.13. Could this be optimized in the future version of Impala?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 13:46:02 GMT</pubDate>
    <dc:creator>Tomas79</dc:creator>
    <dc:date>2022-09-16T13:46:02Z</dc:date>
    <item>
      <title>Impala hash join optimization</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-hash-join-optimization/m-p/80579#M83993</link>
      <description>&lt;P&gt;Hi Cloudera Impala community,&lt;/P&gt;
&lt;P&gt;we have many join queries between Impala (HDFS) and Kudu datasets where the large kudu table is joined with a small HDFS table. I see in many cases, that the HDFS dataset condition returns 0 rows, but the query still scans all the 600mil records in Kudu.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example this query is running for 10min+ and it is clear that the right part of the query, the broadcasted dataset is empty, zero rows. So the optimizer could just skip the scanning and return empty dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Query plan&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="join_with_zero_table.PNG" style="width: 600px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/4883iCD1BA9EBAA17AF40/image-size/large?v=v2&amp;amp;px=999" role="button" title="join_with_zero_table.PNG" alt="join_with_zero_table.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;Max Per-Host Resource Reservation: Memory=17.00MB
Per-Host Resource Estimates: Memory=193.00MB

F02:PLAN FRAGMENT [UNPARTITIONED] hosts=1 instances=1
|  Per-Host Resources: mem-estimate=0B mem-reservation=0B
PLAN-ROOT SINK
|  mem-estimate=0B mem-reservation=0B
|
04:EXCHANGE [UNPARTITIONED]
|  mem-estimate=0B mem-reservation=0B
|  tuple-ids=0,1 row-size=1.62KB cardinality=88114
|
F00:PLAN FRAGMENT [RANDOM] hosts=9 instances=9
Per-Host Resources: mem-estimate=17.00MB mem-reservation=17.00MB
02:HASH JOIN [INNER JOIN, BROADCAST]
|  hash predicates: tab.key1 = pk.key1, tab.key2 = pk.key2, tab.key3 = pk.key3, tab.key4 = pk.key4, tab.root_key3 = pk.root_key3
|  fk/pk conjuncts: tab.key1 = pk.key1, tab.key2 = pk.key2, tab.key3 = pk.key3, tab.key4 = pk.key4, tab.root_key3 = pk.root_key3
|  mem-estimate=17.00MB mem-reservation=17.00MB spill-buffer=1.00MB
|  tuple-ids=0,1 row-size=1.62KB cardinality=88114
|
|--03:EXCHANGE [BROADCAST]
|  |  mem-estimate=0B mem-reservation=0B
|  |  tuple-ids=1 row-size=159B cardinality=88114
|  |
|  F01:PLAN FRAGMENT [RANDOM] hosts=1 instances=1
|  Per-Host Resources: mem-estimate=176.00MB mem-reservation=0B
|  01:SCAN HDFS [work.pk_table_pk pk, RANDOM]
|     partitions=1/1 files=1 size=2.51MB
|     predicates: pk.rn = 1, pk.tr_code IN ('D')
|     stats-rows=249225 extrapolated-rows=disabled
|     table stats: rows=249225 size=2.51MB
|     column stats: all
|     parquet statistics predicates: pk.rn = 1, pk.tr_code IN ('D')
|     parquet dictionary predicates: pk.rn = 1, pk.tr_code IN ('D')
|     mem-estimate=176.00MB mem-reservation=0B
|     tuple-ids=1 row-size=159B cardinality=88114
|
00:SCAN KUDU [base.large_table tab]
   mem-estimate=0B mem-reservation=0B
   tuple-ids=0 row-size=1.46KB cardinality=674357713&lt;/PRE&gt;
&lt;P&gt;The query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;select *
from base.large_table tab join 
work.pk_table_pk pk ON 
         tab.`key1` = pk.`key1` and 
     tab.`key2` = pk.`key2` and 
     tab.`key3` = pk.`key3` and 
     tab.`key4` = pk.`key4` and 
     tab.`root_key3` = pk.`root_key3` 
where pk.tr_code in ('D') and pk.rn =1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is running on CDH 5.13. Could this be optimized in the future version of Impala?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:46:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-hash-join-optimization/m-p/80579#M83993</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2022-09-16T13:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Impala hash join optimization</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-hash-join-optimization/m-p/80605#M83994</link>
      <description>&lt;P&gt;I think the Kudu min-max filter pushdown optimisation in C5.14+ would achieve this:&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/IMPALA-4252" target="_blank"&gt;https://issues.apache.org/jira/browse/IMPALA-4252&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 17:55:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-hash-join-optimization/m-p/80605#M83994</guid>
      <dc:creator>Tim Armstrong</dc:creator>
      <dc:date>2018-10-03T17:55:02Z</dc:date>
    </item>
  </channel>
</rss>

