zoukankan      html  css  js  c++  java
  • oracle性能分析2

    Oracle性能分析

    软件环境:Oracle 11g , 双机RAC.

    问题: 

    大表(千万级行记录)查询、操作慢,经常超时终端(ORA-01013: 用户请求取消当前的操作)

    分析:

    1)分区表

    2)历史数据归档

    解决:

    采用方案2)。

    • 创建历史表
    create table {tablename}_his as select * from {tablename} where ...
    • 禁用除主键之外的索引
    alter index {indexname} unusable;
    • 删除表数据。数据量太大(7444741)无法直接删除(执行半小时无反应中断),需批量删除。(rac环境需要到具体机器上执行)

    declare  
       cursor mycursor is SELECT  ROWID FROM {tablename} WHERE ltl_time < to_date('2017-08-01','YYYY-mm-dd') order by rowid;  
       type rowid_table_type is  table  of rowid index by pls_integer;
       v_rowid   rowid_table_type;
    BEGIN
       open mycursor;
       loop
         fetch   mycursor bulk collect into v_rowid  limit 5000;   --------每次处理5000行,也就是每5000行一提交
         exit when v_rowid.count=0;
         forall i in v_rowid.first..v_rowid.last
            delete from {tablename} nologging  where rowid=v_rowid(i);
         commit;
       end loop;
       close mycursor;
    END;
    • 重建索引
    alter index {indexname} rebuild;



  • 相关阅读:
    python+opencv实现图像自适应阈值的均衡化
    ubuntu添加新的分辨率选项(干货)
    python+opencv检测图像清晰度
    python根据列表创建文件夹,拷贝指定文件
    牛客多校Round 4
    牛客多校Round 3
    HDU多校Round 2
    HDU多校Round 1
    牛客多校Round 2
    牛客多校Round 1
  • 原文地址:https://www.cnblogs.com/lfwolf/p/7740080.html
Copyright © 2011-2022 走看看