我有两张表jr_call_letter
和api_email_applications
。
INDEXES
我需要来自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
我解析了这个查询并看到子查询没有使用索引。
为什么子查询不使用索引?
性能明智,此查询可以吗?