语句如下select t.company_id,t.user_id,t.id,t.provide_area,t.price,t.base_dic_id,t.purveyNumber,t.purveyNumber_dw,t.cas,t.casing,t.product_cname,t.product_ename,t.product_spec,t.define,t.issuance_date,t.auditing_date,t.abate_date,t.key_word,t.chem_alias_name,t.variety,t.producing_area,t.chemical_bond,t.molecular_weight,t.consistency,t.content,t.boil,t.safety_level,a.company_whole_name,a.email,a.phone,a.true_name,t.product_pic_url,a.mobile,a.fax,a.company_web,a.address from purvey_product t,v_product_user a where t.user_id=a.product_user_id and t.abate_date >= now() and t.auditing_state = 1 and a.flag = 0 and a.auditing_state = 1 and a.freeze_state = 0 order by t.auditing_date desc
一个表和试图的联合查询,order by之后非常慢,执行了几分钟了还没出结果
一个表和试图的联合查询,order by之后非常慢,执行了几分钟了还没出结果
select t.company_id,
t.user_id,
t.id,
t.provide_area,
t.price,
t.base_dic_id,
t.purveyNumber,
t.purveyNumber_dw,
t.cas,
t.casing,
t.product_cname,
t.product_ename,
t.product_spec,
t.define,
t.issuance_date,
t.auditing_date,
t.abate_date,
t.key_word,
t.chem_alias_name,
t.variety,
t.producing_area,
t.chemical_bond,
t.molecular_weight,
t.consistency,
t.content,
t.boil,
t.safety_level,
a.company_whole_name,
a.email,
a.phone,
a.true_name,
t.product_pic_url,
a.mobile,
a.fax,
a.company_web,
a.address
from purvey_product t, v_product_user a
where t.user_id = a.product_user_id
and t.abate_date >= now()
and t.auditing_state = 1
and a.flag = 0
and a.auditing_state = 1
and a.freeze_state = 0
order by t.auditing_date desc
在user_id上建索引吧
user_id和product_user_id 加索引试试