`
netfork
  • 浏览: 478920 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

困扰n久的问题,得到解决:Oracle安装一久,就会非常缓慢,拖垮APServer

    博客分类:
  • DB
阅读更多

时间一久,网站的AP服务器访问DB的速度就会非常缓慢,只有重装数据库才能解决问题。
近期又遭遇了上述问题,昨天尤甚,一度以为有小黑客侵犯,打开后台的access log,发现访问并不见多猛,每秒十几个的样子,就这样的量,已经把网站搞挂了。。。。
烦烦烦!!!

反复google不得其解。偶然间发现DB所在的磁盘碎片太多了,整理。。。期待速度可以提高,结果,问题依旧!

再次google,发现有人提到了相同的问题,回答最多的是索引碎片,找到了索引rebuild的方法,使用analyze 命令分析索引,然后得到分析结果,发现真是应该rebuild一下了,把所有的索引rebuild完后,重启WEB服务器,性能明显提高,网站性能基本恢复了。。。

可以松一口气了吗?静观明晚八点以后!

 

 

贴一段索引监视的表和存储过程:

 

create table MONITORINDEX

(

  INDEX_NAME  VARCHAR2(50),

  DEL_LF_ROWS NUMBER,

  LF_ROWS     NUMBER,

  RATE        NUMBER(4,2),

  MONITORDATE DATE default sysdate not null

)

create or replace procedure analyzeindex is

  v_sql varchar2(100);

begin

  for a in (select index_name from all_indexes where owner = USER) loop

    v_sql := ' analyze index ' || a.index_name || ' validate structure';

    execute immediate v_sql;

    insert into monitorindex

      (index_name, del_lf_rows, lf_rows, rate)

      select name,

             del_lf_rows,

             lf_rows,

             round(del_lf_rows * 100 / (lf_rows + del_lf_rows), 2)

        from index_stats;

  end loop;

end analyzeindex;

 

call analyzeindex();

 

create or replace procedure clearallindex is

  v_sql varchar2(100);

begin

  for a in (select index_name from all_indexes where owner = USER) loop

    v_sql := ' alter index ' || a.index_name || ' rebuild';

    execute immediate v_sql;

  end loop;

end clearallindex;

 

call clearallindex();

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics