select中的子查询不使用INDEX MySQL

时间:2017-07-11 11:08:19

标签: mysql

我有两张表jr_call_letterapi_email_applications

INDEXES

  • jr_call_letter:r_id并键入
  • api_email_applications:job_id和status

我需要来自jr_call_letter的数据和api_email_applications中针对特定行的总计数

我写了一个查询,但是包含的子查询没有使用索引。

QUERY

 SELECT job_id as nid,
        job_position,
        date_format(from_unixtime(created_date),
        '%%Y-%%m-%%d %%T') as created_date,
        company_name,
        call_letter_status,
        (SELECT COUNT(*) FROM api_email_applications WHERE owner_id = job_id and status in (1,0)) as total_send,
        created_by_id 
   FROM  jr_call_letter  
   WHERE r_id = 3577478 and type='email' group by job_id order by id desc  

我解析了这个查询并看到子查询没有使用索引。

为什么子查询不使用索引?

性能明智,此查询可以吗?

0 个答案:

没有答案