如题.环境为:WIN2003+ORACLE9.2+ASP访问ORACLE ,进去任务管理中查看时发现CPU有时到100%,有时会降下来10%,平均都在60%左右.不知如何解决这个问题.

解决方案 »

  1.   

    如何知道哪些SQL的执行效率差???
      

  2.   

    SELECT * FROM (SELECT PARSING_USER_ID
    EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,
    sql_text FROM v$sqlarea ORDER BY disk_reads DESC) 
    WHERE ROWNUM<10;查找10条性能差的语句
      

  3.   

    我按上面查出了个语句,你们评说是否性能差,怎样改:
    select count(1) as msgcount from (   select 1  from 留言表 where  回复数=0 and  trunc(留言时间) between trunc(sysdate-20) and trunc(sysdate-3)  and 留言人='张三' and 父留言id is null   Union all  select 1 from TAB_留言表_NEW where  to部门='财务' and trunc(留言时间) > trunc(sysdate-20)  and 留言人<>'张三' and  留言id Not In (  Select distinct 留言id  from 查看表  where 收信部门='财务' and  阅读人='张三' and trunc(阅读时间)>trunc(sysdate-20)  )  ) a
    --------------------------------------------------------------
    表结构:
    1.留言表
      留言ID   VARCHAR2(10) not null,
      主题     VARCHAR2(50),
      称呼     VARCHAR2(100),
      内容     VARCHAR2(1000),
      留言时间 DATE,
      留言部门 VARCHAR2(100),
      留言人   VARCHAR2(10)
    )
    2.查看表
    (
      留言ID   VARCHAR2(10) not null,
      收信部门 VARCHAR2(30) not null,
      阅读人   VARCHAR2(30) not null,
      阅读时间 DATE
    )
      

  4.   

    and  阅读人='张三' and trunc(阅读时间)>trunc(sysdate-20)  )  ) 需要把确定的查询条件放在最后,以第一次返回的结果集越少越好比如,这两个并行的条件,把:阅读人='张三'  放在where子句的最后把trunc(阅读时间)>trunc(sysdate-20)  )  放在最靠近where关键字的地方,就比较好当然,具体一个sql语句执行效果好不好,还是要看执行计划
      

  5.   

    我按上面查出了个语句,你们评说是否性能差,怎样改:
    select count(1) as msgcount from (   select 1  from 留言表 where  回复数=0 and  trunc(留言时间) between trunc(sysdate-20) and trunc(sysdate-3)  and 留言人='张三' and 父留言id is null   Union all  select 1 from 留言表_NEW where  to部门='财务' and trunc(留言时间) > trunc(sysdate-20)  and 留言人<>'张三' and  留言id Not In (  Select distinct 留言id  from 查看表  where 收信部门='财务' and  阅读人='张三' and trunc(阅读时间)>trunc(sysdate-20)  )  ) a
    表结构:
    1.留言表(
      留言ID   VARCHAR2(10) not null,
      主题     VARCHAR2(50),
      称呼     VARCHAR2(100),
      内容     VARCHAR2(1000),
      留言时间 DATE,
      留言部门 VARCHAR2(100),
      留言人   VARCHAR2(10),
      运单号   VARCHAR2(20),
      父留言ID VARCHAR2(10),
      类型     VARCHAR2(10),
      TO部门   VARCHAR2(10),
      TO用户   VARCHAR2(10),
      回复数   NUMBER(6),
      浏览数   NUMBER(6)
    )
    2.查看表
    (
      留言ID   VARCHAR2(10) not null,
      收信部门 VARCHAR2(30) not null,
      阅读人   VARCHAR2(30) not null,
      阅读时间 DATE
    )
    --------------
    上面有误,,以这个为准
      

  6.   

    有pl/sql develop工具嘛,有的话,explan plan window窗口
      

  7.   

    看看一上来是 by index呢,还是table access full后者很不好
      

  8.   

    有两个FULL,一个BYINDEX,那如何改进呢....
      

  9.   

    有两个FULL,一个BYINDEX,那如何改进呢....
    我将{查看表}加了索引:阅读时间+收信部门 + 阅读人;还是FULL的.没有改进