MYSQL数据库是怎么设置索引,优化查询报表查询效率的

SQL不复杂,数据量大。优化查询报表查询效率

SQL 小白不白 发布于 2023-11-9 14:57
1min目标场景问卷 立即参与
回答问题
悬赏:0 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
luojian0323Lv7资深互助
发布于2023-11-9 15:06

根据常用的过滤条件字段作索引,比如日期字段等

最佳回答
0
ZxxTLv6初级互助
发布于2023-11-9 15:02

具体由多少行呢,可以多设置筛选参数,少用条件属性、公式、设置分页。

  • 小白不白 小白不白(提问者) with a as (select t1.*,t2.name from fr_qdkc_tb t1 left join bd_psndoc_new t2 on t1.tbr=t2.code union all select t1.*,t3.user_name from fr_qdkc_tb t1 left join dw_zt_sx_xhgwda t3 on t1.tbr=t3.user_code ) select distinct * from a where name is not NULL and org_code in (\'${ORG_NAME}\') and month=\'${mon}\' ${if(len(pq) == 0,\"\",\"and pqname in (\'\" + pq + \"\')\")} ${if(len(kh) == 0,\"\",\"and customer_name in (\'\" + kh + \"\')\")} ${if(len(qd) == 0,\"\",\"and customer_qd in (\'\" + qd + \"\')\")} ${if(len(xh) == 0,\"\",\"and xh in (\'\" + xh + \"\')\")} order by tbsj DESC
    2023-11-09 15:16 
  • 小白不白 小白不白(提问者) 是用的参数,但是是因为子查询?页面一打开就是加载的状态,数据就3W多条,也不是很多
    2023-11-09 15:17 
  • 3关注人数
  • 164浏览人数
  • 最后回答于:2023-11-9 15:06
    请选择关闭问题的原因
    确定 取消
    返回顶部