Index on join and where
<p>Given the next SQL statement:</p>

<pre><code>Select * 
  from A join B
           on A.id1=B.id1 and 
              A.id2=B.id2
 where A.year=2016
   and B.year=2016
</code></pre>

<p>and knowing table <code>A</code> is much smaller than table <code>B</code>, so I need the database first to access <code>A</code> table by year, then join, then filter <code>B</code> table by year, my question is:</p>

<p>does it make sense to create an index over <code>B</code> like <code>(id1,id2,year)</code> for improve performance?</p>

<p>Many thanks!</p>