title: Mysql Indexing and Joins
body: <p>I have a query </p>
  
  <pre><code>SELECT `a`.restid, `b`.`name` AS execname, `c`.`dept_name`
  FROM `tk_ticket` AS a
  INNER JOIN `tk_acp_users` AS b ON `a`.`exec_id` = `b`.`id`
  INNER JOIN `tk_ticket_dept` AS c ON `a`.`dept_id` = `c`.`dept_id`
  WHERE `a`.`dept_id` IN(9,11)
  AND `a`.`status` =  0
  ORDER BY `a`.`date` DESC, `a`.`dept_id`
  </code></pre>
  
  <p>Explain output</p>
  
  <pre><code>1   SIMPLE  a   ALL exec_id_2   5391    Using  where; Using filesort
  1   SIMPLE  b   eq_ref  PRIMARY PRIMARY 2 tk_new_db.a.exec_id   1   
  1   SIMPLE  c   eq_ref  PRIMARY PRIMARY 1 tk_new_db.a.dept_id   1   Using where
  </code></pre>
  
  <p>When i run an explain I get a full table scan for table a, how do i prevent this from happening i added a key (exec_id,dept_id,status) but this index is not considered.</p>