java程序耗时及数据库执行效
偶然得知web网页打开页面过慢
通过检测方法耗时
System.out.println(“SLAMonitorThread.main() start”);
StopWatch sw = new StopWatch();
sw.start();
TimeUnit.SECONDS.sleep(1L);
sw.split();
System.out.println(
“SLAMonitorThread.main() end. split:” + sw.getSplitTime() + ", " + sw.toSplitString());
TimeUnit.SECONDS.sleep(1L);
sw.split();
System.out.println(
“SLAMonitorThread.main() end. split:” + sw.getSplitTime() + ", " + sw.toSplitString());
TimeUnit.SECONDS.sleep(1L);
sw.split();
System.out.println(
“SLAMonitorThread.main() end. split:” + sw.getSplitTime() + ", " + sw.toSplitString());
TimeUnit.SECONDS.sleep(1L);
System.out.println(“SLAMonitorThread.main() end. end:” + sw.getTime() + ", " + sw.toString());
long start = System.currentTimeMillis();
TimeUnit.SECONDS.sleep(1L);
System.out.println("it consumes " + (System.currentTimeMillis() - start) + "ms");
————————————————
查看耗时较高的代码 查看代码中sql,表,数据库信息
查看表数据是否过多,表是否存在索引 ,语句条件是否根据索引等
定位表中索引字段
select * from user_indexes where table_name=upper(‘表名’)
select * from user_ind_columns where index_name=(‘索引名’)
进一步排查