title: How to optimize MySQL query which contains table and left join of sql view
body: <p>I have this query:</p>
  
  <pre><code>SELECT a.id, b.discount FROM (a LEFT JOIN b ON b.id_a = a.id);
  </code></pre>
  
  <p>EXPLAIN command for this query is this:</p>
  
  <pre><code>id  select_type   table  type   possible_keys   key       key_len  ref    rows   Extra
  1    SIMPLE        a      index  NULL            PRIMARY   4        NULL   1489   Using index
  1    SIMPLE        b      ALL    NULL            NULL      NULL     NULL   819   
  </code></pre>
  
  <p>A is table with 1489 rows and B is a SQL view. Now I understand, that MySQL has to do 1489*819 operations which is way too not-optimized operation. If B was a table, I would create an index for column id_a, but I have no idea what to do with SQL view.</p>
  
  <p>Anybody can help ?</p>