explain select tt.ticketnumber, tt.timein, tt.projectreference, tt.estimatedshipdate, tt.actualshipdate, tt.clientid, tt.servicecodes, tt.repetitiveid, tt.currentprocess, tt.currentdpperson, tt.recordvolume, tt.dpprinted, et.country, et_1.country, do.custname from tt, et, et as et_1, do where tt.submittime is null and tt.actualpc = et.employid and tt.assignedpc = et_1.employid and tt.clientid = do.custnmbr;
select命令中出现的表定义如下:
※表定义
表 列 列类型 tt actualpc char(10) tt assignedpc char(10) tt clientid char(10) et employid char(15) do custnmbr char(15)
※索引
表 索引 tt actualpc tt assignedpc tt clientid et employid (主键) do custnmbr (主键)
※tt.actualpc值分布不均匀
在进行任何优化之前,explain对select执行分析的结果如下:
table type possible_keys key key_len ref rows extra et all primary null null null 74 do all primary null null null 2135 et_1 all primary null null null 74 tt all assignedpc,clientid,actualpc null null null 3872 range checked for each record (key map: 35)
table type possible_keys key key_len ref rows extra tt all assignedpc,clientid,actualpc null null null 3872 where used do all primary null null null 2135 range checked for each record (key map: 1) et_1 all primary null null null 74 range checked for each record (key map: 1)