即使没有下面的查询也order by
很慢,我不知道为什么。我猜它是,where date_affidavit_file
但我怎样才能让它快速order by
呢?也许 job_id 上的 sublect 与 where 匹配,然后将其传递到代码的其余部分,但我仍然需要像这样通过服务器订购服务器名称。有什么建议么?
explain select sql_no_cache court_county, job.id as jid, job_status,
DATE_FORMAT(job.datetime_served, '%m/%d/%Y') as dserved ,
CONCAT(server.namefirst, ' ', server.namelast) as servername, client_name,
DATE_FORMAT(job.datetime_received, '%m/%d/%Y') as dtrec ,
DATE_FORMAT(job.datetime_give2server, '%m/%d/%Y') as dtg2s,
DATE_FORMAT(date_kase_filed, '%m/%d/%Y') as dkf,
DATE_FORMAT(job.date_sent_to_court, '%m/%d/%Y') as dtstc ,
TO_DAYS(datetime_served )-TO_DAYS(date_kase_filed) as totaldays from job
left join kase on kase.id=job.kase_id
left join server on job.server_id=server.id
left join client on kase.client_id=client.id
left join LUcourt on LUcourt.id=kase.court_id
where date_affidavit_filed is not null and date_affidavit_filed !='' order by servername;
+----+-------------+---------+--------+----------- ------------+---------+---------+------------------ -----+--------+------------------------------------ ------------+ | 编号 | 选择类型 | 表| 类型 | 可能的键 | 关键 | key_len | 参考 | 行 | 额外 | +----+-------------+---------+--------+----------- ------------+---------+---------+------------------ -----+--------+------------------------------------ ------------+ | 1 | 简单 | 工作 | 全部 | date_affidavit_filed | 空 | 空 | 空 | 365212 | 使用哪里;使用临时的;使用文件排序 | | 1 | 简单 | 加濑 | eq_ref | 初级 | 初级 | 4 | pserve.job.kase_id | 1 | | | 1 | 简单 | 服务器 | eq_ref | 初级 | 初级 | 4 | pserve.job.server_id | 1 | | | 1 | 简单 | 客户 | eq_ref | 初级 | 初级 | 4 | pserve.kase.client_id | 1 | | | 1 | 简单 | 卢考特 | eq_ref | 初级 | 初级 | 4 | pserve.kase.court_id | 1 | | +----+-------------+---------+--------+----------- ------------+---------+---------+------------------ -----+--------+------------------------------------ ------------+