设为首页 加入收藏

TOP

64W数据表,查询数据执行时间为139s,优化为1s(二)
2014-11-24 08:22:01 来源: 作者: 【 】 浏览:3
Tags:64W 数据 查询 执行 时间 139s 化为
------ ---------- ---------- ---------- ---------- ----------
total 4 0.95 46.98 266 16820 20 100
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 87
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
100 100 100 VIEW (cr=16819 pr=266 pw=4795 time=46976922 us cost=484 size=319485 card=1805)
100 100 100 WINDOW SORT (cr=16819 pr=266 pw=4795 time=46976616 us cost=484 size=332120 card=1805)
210483 210483 210483 TABLE ACCESS BY INDEX ROWID CUT_BATCH_TEST (cr=16819 pr=0 pw=0 time=479564 us cost=409 size=332120 card=1805)
328719 328719 328719 INDEX RANGE SCAN IDX_CUT_BATCH_TEST1 (cr=645 pr=0 pw=0 time=704811 us cost=257 size=0 card=2518)(object id 82729)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 0.00 0.00
direct path write temp 182 0.69 46.11
direct path read temp 19 0.01 0.12
SQL*Net more data to client 7 0.00 0.00
********************************************************************************
在以上trace文件中,其direct path write temp等待时间占到了整个查询时间的99%。
为了排序工作在临时区域读写时,等待direct path read temp、direct path write temp事件。
这个等待事件收从oracle 10g起被分类的,oracle 9i为止是通过direct path read、direct path write等待观察的。
排序段上的 direct path I/O是在需要排序的数据比排序所分配的PGA内存区大时发生的。
因此在排序工作时若大量发生direct path read temp、direct path write temp等待,就可以通过追加分配内存区域而避免等待。
SQL> select event#,name,parameter1,parameter2,parameter3 from v$event_name where name = 'direct path read temp';
EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3
---------- ------------------------------ --------------- --------------- ---------------
195 direct path read temp file number first dba block cnt
SQL> select event#,name,parameter1,parameter2,parameter3 from v$event_name where name = 'direct path write temp';
EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3
---------- ------------------------------ --------------- --------------- ---------------
197 direct path write temp file number first dba block cnt
1、应用程序层
检查需要排序的sql语句是否已经最优化。不必要的排序操作会导致CPU浪费、PGA区域浪费、磁盘I/O浪费。从UNION和UNION ALL的性能差异上可以得知,只靠减少不必要的排序操作,也能解决许多问题。
2、oracle内存层
在进程上分配的工作区大小内一次性实现的排序称为One pass sort。与此相反的情况称为Multi pass sort。
发生Multi pass sort时,排序工作过程中将排序结果读写到排序段(sort segment)区域,因此发生direct path read temp、direct path write temp等待。
如果该等待大量发生,就可以适当提高pga_aggregate_target值,以此消除问题。
oracle在调优指南上推荐如下设定pga_aggregate_target值。
OLTP:pga_aggregate_target=(total_mem * 80%) * 20%
OLAP:pga_aggregate_target=(total_mem * 80%) * 50%
上述的意思是,假设OS本身使用20%左右的内存,OLTP系统上使用剩余内存的20%左右,OLAP系统因为排序工作较多,所以使用剩余内存的50%左右。
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle临时表游标未释放导致回滚.. 下一篇如何从PowerDesign数据库建模导出..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·一篇说人话的文章, (2025-12-27 07:50:09)
·Python Web框架哪家 (2025-12-27 07:50:06)
·基于Python的数据分 (2025-12-27 07:50:03)
·深入理解 Java 集合 (2025-12-27 07:22:48)
·Java集合框架全面解 (2025-12-27 07:22:45)