数据总量大概100万,下面的执行后需要25秒左右,请帮忙优化
select straight_join count(c.company_id) as count_com
from xx_hm_companies c
inner join xx_users_hrmanagers h
on c.company_id=h.company_id
inner join xx_pd_accounts pa
on pa.`enterprise_id`=h.`enterprise_id`
where
not exists
( select 1 from xx_hm_applications a where a.`company_id`=c.company_id and FROM_UNIXTIME(a.apply_date)>='2009-07-30' and FROM_UNIXTIME(a.apply_date)<='2009-07-30')
select straight_join count(c.company_id) as count_com
from xx_hm_companies c
inner join xx_users_hrmanagers h
on c.company_id=h.company_id
inner join xx_pd_accounts pa
on pa.`enterprise_id`=h.`enterprise_id`
where
not exists
( select 1 from xx_hm_applications a where a.`company_id`=c.company_id and FROM_UNIXTIME(a.apply_date)>='2009-07-30' and FROM_UNIXTIME(a.apply_date)<='2009-07-30')
from xx_hm_companies c
inner join xx_users_hrmanagers h
on c.company_id=h.company_id
inner join xx_pd_accounts pa
on pa.`enterprise_id`=h.`enterprise_id`
left join (select company_id from xx_hm_applications where FROM_UNIXTIME(a.apply_date)='2009-07-30') a
on a.`company_id`=c.company_id
where c.company_id is null