title: How to create indexes for query for better performance in sybase ase 15.4?
body: <p>I have 3 large tables: tab1, tab2, tab3, tab4. I have a sql query like:</p>
  
  <pre><code>select * from tab1 a, tab2 b, tab3 c, tab4 d
  where 
      a.c1 = b.c1
  and b.c2 = c.c2
  and c.c3 = d.c3
  
  and a.c4 = c.c4
  
  and a.c3 = @var3
  and a.c4 = @var4
  and b.date &gt;= @d1 and b.date &lt;=@d2
  and b.c5 =@var5
  group by d.c6, a.c4, c.c7
  order by d.c6, a.c4, c.c7
  </code></pre>
  
  <p>There are indexes created as: for each column in the where condition, there is a index created. For example, there are 3 columns in tab1 used in above query: c1, c3, c4. there are 3 indexes created: 
  index on c1, index on c3, index onc4. </p>
  
  <p>Same for all other tables. </p>
  
  <p>Questions:
  1. How to create a index for those columns appear in where condition? single colum index or combined index? For example, for tab1, one index include 3 columns c1, c3, c4 or 3 index for each single column?<br>
  2. If index also should be create for columns in group by?<br>
  3. If the order in where condition is important? For example, following 3 has any difference on performance?  </p>
  
  <pre><code>where 
      a.c1 = b.c1
  and b.c2 = c.c2
  and c.c3 = d.c3
  
  and a.c4 = c.c4  ----duplicate join???
  
  and a.c3 = @var3
  and a.c4 = @var4
  and b.date &gt;= @d1 and b.date &lt;=@d2
  and b.c5 =@var5
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>where 
  a.c3 = @var3
  and a.c4 = @var4
  and b.date &gt;= @d1 and b.date &lt;=@d2
  and b.c5 =@var5
  
  and a.c1 = b.c1
  and b.c2 = c.c2
  and c.c3 = d.c3
  and a.c4 = c.c4  --duplicate join???
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>where 
  a.c3 = @var3
  and a.c4 = @var4
  and b.date &gt;= @d1 and b.date &lt;=@d2
  and b.c5 =@var5
  
  and a.c1 = b.c1
  and b.c2 = c.c2
  and c.c3 = d.c3
  </code></pre>