多表关联查询优化方案
以下是我的minidao的sqlselect count(1) from (select techown_report.ID as ID,techown_report.name as apiname,
t_s_base_user.realname as sale,
techown_api.accountname as accountname,
techown_customer.customershort as customershort,
techown_api.price as price,
industry.typename as industryclassification,
account.typename as accounttype,
billingway.typename as billingway,
paymentway.typename as paymentway from techown_report
LEFT JOIN techown_api on techown_report.name=techown_api.apiname
LEFT JOIN techown_customer on techown_api.customerid=techown_customer.id
LEFT JOIN t_s_base_user on t_s_base_user.username=techown_customer.sale
LEFT JOIN (select t_s_type.typecode,t_s_type.typename fromt_s_type LEFT JOIN t_s_typegroup on t_s_typegroup.ID=t_s_type.typegroupid where t_s_typegroup.typegroupcode='industry') as industry on techown_api.industryclassification=industry.typecode
LEFT JOIN (select t_s_type.typecode,t_s_type.typename fromt_s_type LEFT JOIN t_s_typegroup on t_s_typegroup.ID=t_s_type.typegroupid where t_s_typegroup.typegroupcode='account') as account on techown_api.accounttype=account.typecode
LEFT JOIN (select t_s_type.typecode,t_s_type.typename fromt_s_type LEFT JOIN t_s_typegroup on t_s_typegroup.ID=t_s_type.typegroupid where t_s_typegroup.typegroupcode='billingway') as billingway on techown_api.billingway=billingway.typecode
LEFT JOIN (select t_s_type.typecode,t_s_type.typename fromt_s_type LEFT JOIN t_s_typegroup on t_s_typegroup.ID=t_s_type.typegroupid where t_s_typegroup.typegroupcode='paymentway') as paymentway on techown_api.paymentway=paymentway.typecode
where 1=1
<#if accountname ?exists && accountname ?length gt 0>
and accountname like :accountname
</#if>
<#if customershort ?exists && customershort ?length gt 0>
and customershort like :customershort
</#if>
GROUP BY techown_report.name
ORDER BY techown_report.name) m求优化方案。该如何做?
非jeecg的问题,尽量不要发,可以看下执行计划,加下索引 admin 发表于 2018-6-8 11:59 static/image/common/back.gif
非jeecg的问题,尽量不要发,可以看下执行计划,加下索引
只是我实在想不到方案:dizzy: 所谓急病乱投医
页:
[1]