查询语句优化,现在遇到一个问题,语句我认为已经很简单了,但查询数据量大的时候还是很慢,即使我只选择了时间范围查询(比如去年到今天一年),其他控件都是空白的。 /* SELECT a.product_no, a.batch_number, a.busi_type, a.furnace_no, a.matrial_gz, a.inv_gz, a.inv_model, a.define01, a.executive_standard, a.num, a.update_date, a.theory_weight, a.inv_name, a.define05, a.define08, a.remain_num, a.define15, a.icheck, a.define06, a.define07, a.inv_code, a.define09, a.define10, a.ware_name, a.define02, a.define03, a.define13, a.define14, a.create_date, a.check_time, a.location_name, a.define22, c.realname AS check_name , d.realname as create_name, CASE WHEN a.remain_num = '0' AND a.busi_type<>'OutInvol' THEN '出库' WHEN a.remain_num > '0' AND a.busi_type<>'OutInvol' THEN '库存' ELSE '内盘出库' END AS zt FROM pd_store_record a LEFT JOIN sys_user c ON a.`check_user_id`=c.`id` LEFT JOIN sys_user d ON a.`create_user_id`=d.`id` WHERE a.busi_type <> 'OutStock' AND a.ideleted=0 and a.create_date BETWEEN '${startTime}' AND '${endTime}' ${if(kczt==1," and a.remain_num > '0' and a.busi_type<>'OutInvol'","")} ${if(kczt==2," and a.remain_num = '0' and a.busi_type<>'OutInvol'","")} ${if(kczt==3,"and a.busi_type='OutInvol'","")} ${if(len(icheck) == 0,"","and a.icheck='"+icheck+"'")} ${if(len(ck)==0,"","and a.ware_name='"+ck+"'")} ${if(len(inv_model) == 0,"","and a.inv_model like '%" + inv_model + "%'" )} ${if(len(define13) == 0,"","and a.define13 like '%" + define13 + "%'" )} ${if(len(define22) == 0,"","and a.define05 like '%" + define22 + "%'" )} ${if(len(TEXTT) == 0,"","and a.define22 like '%" + TEXTT + "%'" )} ${if(len(product_no) == 0,"","and a.product_no like '%" + product_no + "%'" )} ${if(len(define0222) == 0,"","and a.define02 in ('" + define0222 + "')")} ${if(len(furnace_no) == 0,"","and a.furnace_no like '%" + furnace_no + "%'" )} ${if(len(batch_number) == 0,"","and a.batch_number like '%" + batch_number + "%'" )} ${if(len(define03) == 0,"","and a.define03= '" + define03 + "'" )} ${if(len(define01) == 0,"","and a.define01 like '" + define01 + "'" )} ${if(len(inv_gz) == 0,"","and a.inv_gz like '%" + inv_gz + "%'" )} ${if(len(executive_standard) == 0,"","and a.executive_standard like '%" + executive_standard + "%'" )} ${if(len(define07) == 0,"","and a.define07='"+define07+"'")} ${if(len(matrial_gz) == 0,"","and a.matrial_gz= '" + matrial_gz + "'" )} */ |