java 排查性能问题,性能问题排查

本文详细记录了一次SQL查询优化的过程,强调了避免盲目优化和重视已知问题的重要性。通过分析和重构SQL语句,实现了COUNT(*)操作和分页功能,并通过UNION ALL提高查询效率。同时,对页面性能进行了逐步排查,揭示了优化细节对于提升系统整体性能的关键作用。
摘要由CSDN通过智能技术生成

一 总结概要:

1.首先解决问题的方向不对,没有证实靠猜测就盲目优化SQL语句.(其实SQL语句性能不慢的,猜测 in(11,22,33,...) 语句的性能问题)

2.对早已经发现的问题熟视无睹,明明知道页面展现有性能问题(IT性能慢,FIREFOX正常没有引起足够的重视)

3.在自己写纯SQL语句优化无结果的情况下,重新审视过去走过的弯路

4.不要放过每个细节,自己思路一定要清晰,坚持就是胜利了

二 实际操作过程:

1.数据库环境 192.168.0.70  cem_vcc

2.需要优化的SQL语句

基本SQL  A:    select vl.*  from vccrawlog vl,

cem_cc_operator op,

cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id

and ag.site_id=2010010

and auto_rec_name is not null and is_rec_deleted=0  and endtime is not null

and  vl.site_id=2010010

and acd_group_id in

(542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652) and ( (callee_id =op.site_extension and call_type=0 ) or( caller_id =op.site_extension and call_type=1  ))

order by sequence   desc;

要求 1.A语句需要进行 COUNT(*) 操作

2.A语句需要进行 分页

业务简要说明: 查询VCCRAWLOG满足所有acd_group_id in

(542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652) 里面座席数据.

http://localhost:8080/vcc10/page/listRecords.action?&site=8ins

mysql 命令

show create table vccrawlog;

show index from vccrawlog;

SQL_NO_CACHE 不用缓存

select DISTINCT

*************************************************

1.COUNT语句

select sum(cnt) from

(

select count(*) cnt from vccrawlog vl, cem_cc_operator op, cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id

and vl.site_id=op.site_id and vl.caller_id =op.site_extension and vl.call_type=1

and ag.site_id=2010010 and vl.auto_rec_name is not null and vl.is_rec_deleted=0  and vl.endtime is not null

and ag.acd_group_id in (542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652)

union all

select count(*) cnt from vccrawlog vl, cem_cc_operator op, cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id

and vl.site_id=op.site_id and vl.callee_id =op.site_extension and vl.call_type=0

and ag.site_id=2010010 and vl.auto_rec_name is not null and vl.is_rec_deleted=0  and vl.endtime is not null

and ag.acd_group_id in (542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652)

) a;

说明 通过union all 可以分别利用 caller_id 和 callee_id索引

****************************************************

2 .countSql:

select sum(cnt) from

(

select count(*) cnt from vccrawlog vl, ( select op.site_id,op.site_extension from cem_cc_operator op, cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id

and ag.site_id=2010010

and ag.acd_group_id in (542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652)

union select 2010010,20100108888 ) operators

where vl.site_id=operators.site_id and vl.caller_id =operators.site_extension and vl.call_type=1

and vl.auto_rec_name is not null and vl.is_rec_deleted=0  and vl.endtime is not null

union all

select count(*) cnt from vccrawlog vl, ( select op.site_id,op.site_extension from cem_cc_operator op, cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id

and ag.site_id=2010010

and ag.acd_group_id in (542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652)

union select 2010010,20100108888 ) operators

where vl.site_id=operators.site_id and vl.callee_id =operators.site_extension and vl.call_type=0

and vl.auto_rec_name is not null and vl.is_rec_deleted=0  and vl.endtime is not null

) a;

说明:

select op.site_id,op.site_extension from cem_cc_operator op, cem_cc_operator_acd_group ag

where op.user_id=ag.user_id and ag.site_id=op.site_id    and ag.site_id=2010010

and ag.acd_group_id in (542,632,622,862,752,692,702,822,552,722,532,662,812,562,642,782,832,732,872,802,792,742,712,652)

union select 2010010,20100108888

可以去掉大量的重复数据

******************************************************************************

页面性能排查:

1.逐步执行

alert('aaaaaaa');

2.暂时删除觉得没有问题的部分

------君临天下,舍我其谁------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值