关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、418799587 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 12228|回复: 2

[Minidao] 多表关联查询优化方案

[复制链接]
发表于 2018-6-8 11:51:11 | 显示全部楼层 |阅读模式
以下是我的minidao的sql
  1. select count(1) from (select techown_report.ID as ID,
  2. techown_report.name as apiname,
  3. t_s_base_user.realname as sale,
  4. techown_api.accountname as accountname,
  5. techown_customer.customershort as customershort,
  6. techown_api.price as price,
  7. industry.typename as industryclassification,
  8. account.typename as accounttype,
  9. billingway.typename as billingway,
  10. paymentway.typename as paymentway from techown_report
  11. LEFT JOIN techown_api on techown_report.name=techown_api.apiname
  12. LEFT JOIN techown_customer on techown_api.customerid=techown_customer.id
  13. LEFT JOIN t_s_base_user on t_s_base_user.username=techown_customer.sale
  14. LEFT JOIN (select t_s_type.typecode,t_s_type.typename from  t_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
  15. LEFT JOIN (select t_s_type.typecode,t_s_type.typename from  t_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
  16. LEFT JOIN (select t_s_type.typecode,t_s_type.typename from  t_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
  17. LEFT JOIN (select t_s_type.typecode,t_s_type.typename from  t_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
  18. where 1=1
  19. <#if accountname ?exists && accountname ?length gt 0>
  20.         and accountname like :accountname
  21. </#if>
  22. <#if customershort ?exists && customershort ?length gt 0>
  23.         and customershort like :customershort
  24. </#if>
  25. GROUP BY techown_report.name
  26. ORDER BY techown_report.name) m
复制代码
求优化方案。该如何做?


发表于 2018-6-8 11:59:19 | 显示全部楼层
非jeecg的问题,尽量不要发,可以看下执行计划,加下索引
 楼主| 发表于 2018-6-8 17:19:24 | 显示全部楼层
admin 发表于 2018-6-8 11:59
非jeecg的问题,尽量不要发,可以看下执行计划,加下索引

只是我实在想不到方案   所谓急病乱投医
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表