title: Optimizing multiple joins in HiveQL
body: <p>I have 3 tables, Food, Invoice, and Branch.</p>
  <pre><code>Food
  |  foodID  |   productCode  |  foodName |  foodQty |
  | -------- | -------------- | --------- | -------- |
  |     1    |     000001     | Mozerella |    50    |
  |     2    |     000002     |   Tomato  |    40    |
  |     3    |     000003     |   flour   |    60    |
  
  Invoice
  |   id   | foodID  | branchID |  qtySold |
  | ------ | ------- | -------- | -------- |
  |   1    |    1    |     2    |    3.5   |
  |   2    |    3    |     2    |    1.5   |
  |   3    |    3    |     5    |    2     |
  |   4    |    2    |     5    |    5.5   |
  
  Branch
  | branchID | branchName |
  | -------- | ---------- |
  |     1    |   branch1  |
  |     2    |   branch2  |
  |     3    |   branch3  |
  </code></pre>
  <p>I need to write a HiveQL statement to get the following output</p>
  <pre><code>| productCode | productName | branchName | total quantity sold |
  | ----------- | ----------- | ---------- | ------------------- |
  </code></pre>
  <p>This is my HiveQL statement</p>
  <pre><code>Select f.productCode as productCode, f.productName as productName, b.branchName as branchName, 
  SUM(i.qtySold) as qtySold 
  FROM Invoice i JOIN Food f ON (i.foodID = f.foodID) 
  JOIN Branch b ON (i.branchID = b.branchID)
  </code></pre>
  <p>Are there other ways to join that could potentially maximize the query speed?</p>