title: How can I avoid a full table scan on this mysql query?
body: <pre><code>explain
  select
      *
  from
      zipcode_distances z 
  inner join
      venues v    
      on z.zipcode_to=v.zipcode
  inner join
      events e
      on v.id=e.venue_id
  where
      z.zipcode_from='92108' and
      z.distance &lt;= 5
  </code></pre>
  
  <p>I'm trying to find all "events at venues within 5 miles of zipcode 92108", however, I am having a hard time optimizing this query.</p>
  
  <p>Here is what the explain looks like:</p>
  
  <pre><code>id, select_type, table, type, possible_keys, key, key_len, ref, rows, Extra
  
  1, SIMPLE, e, ALL, idx_venue_id, , , , 60024, 
  1, SIMPLE, v, eq_ref, PRIMARY,idx_zipcode, PRIMARY, 4, comedyworld.e.venue_id, 1, 
  1, SIMPLE, z, ref, idx_zip_from_distance,idx_zip_to_distance,idx_zip_from_to, idx_zip_from_to, 30, const,comedyworld.v.zipcode, 1, Using where; Using index
  </code></pre>
  
  <p>I'm getting a full table scan on the "e" table, and I can't figure out what index I need to create to get it to be fast.</p>
  
  <p>Any advice would be appreciated</p>
  
  <p>Thank you</p>