zoukankan      html  css  js  c++  java
  • Oracle 表格碎片的查看方法

    参考:How to Find Fragmentation for Tables and LOBs (文档 ID 2132004.1)

    1. Tables in MSSM (Manual Segment Space Management) tablespaces (对于手动段管理方式表空间下的表)

    exec dbms_stats.gather_table_stats('<OWNER>','<TABLE NAME>');

    select owner,table_name,round((blocks*8),2)||' kb' "TABLE SIZE",round((num_rows*avg_row_len/1024),2)||' kb' "ACTUAL DATA" from dba_tables where table_name='<YOUR TABLES'S NAME>';

    2. Tables in ASSM(Automatic Segment Space Management) tablespaces (对于自动段管理方式表空间下的表)

    set serveroutput on
    declare
    v_unformatted_blocks number;
    v_unformatted_bytes number;
    v_fs1_blocks number;
    v_fs1_bytes number;
    v_fs2_blocks number;
    v_fs2_bytes number;
    v_fs3_blocks number;
    v_fs3_bytes number;
    v_fs4_blocks number;
    v_fs4_bytes number;
    v_full_blocks number;
    v_full_bytes number;
    begin
    dbms_space.space_usage ('<schema>', '<table name>', 'TABLE', v_unformatted_blocks,
    v_unformatted_bytes, v_fs1_blocks, v_fs1_bytes, v_fs2_blocks, v_fs2_bytes,
    v_fs3_blocks, v_fs3_bytes, v_fs4_blocks, v_fs4_bytes, v_full_blocks, v_full_bytes);
    dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);
    dbms_output.put_line('FS1 Blocks = '||v_fs1_blocks);
    dbms_output.put_line('FS2 Blocks = '||v_fs2_blocks);
    dbms_output.put_line('FS3 Blocks = '||v_fs3_blocks);
    dbms_output.put_line('FS4 Blocks = '||v_fs4_blocks);
    dbms_output.put_line('Full Blocks = '||v_full_blocks);
    end;
    /

    unformatted_blocks : Total number of blocks unformatted. unformatted blocks are blocks that are available for immediate use (below the true high water mark) but haven't yet had any data. when the table says I'm full, we pull a bunch of blocks down into the table from above the HWM and they would all be unformatted until you use them.
    fs1_blocks : Number of blocks having at least 0 to 25% free space
    fs2_blocks : Number of blocks having at least 25 to 50% free space
    fs3_blocks : Number of blocks having at least 50 to 75% free space
    fs4_blocks : Number of blocks having at least 75 to 100% free space
    ful1_blocks : Total number of blocks full in the segment

    3.To find fragmentation at partition level (分区基本上查看碎片)

    set serveroutput on
    declare
    v_unformatted_blocks number;
    v_unformatted_bytes number;
    v_fs1_blocks number;
    v_fs1_bytes number;
    v_fs2_blocks number;
    v_fs2_bytes number;
    v_fs3_blocks number;
    v_fs3_bytes number;
    v_fs4_blocks number;
    v_fs4_bytes number;
    v_full_blocks number;
    v_full_bytes number;
    begin
    dbms_space.space_usage ('<schema>', '<table name>', 'TABLE PARTITION', v_unformatted_blocks,
    v_unformatted_bytes, v_fs1_blocks, v_fs1_bytes, v_fs2_blocks, v_fs2_bytes,
    v_fs3_blocks, v_fs3_bytes, v_fs4_blocks, v_fs4_bytes, v_full_blocks, v_full_bytes, <partition name>);
    dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);
    dbms_output.put_line('FS1 Blocks = '||v_fs1_blocks);
    dbms_output.put_line('FS2 Blocks = '||v_fs2_blocks);
    dbms_output.put_line('FS3 Blocks = '||v_fs3_blocks);
    dbms_output.put_line('FS4 Blocks = '||v_fs4_blocks);
    dbms_output.put_line('Full Blocks = '||v_full_blocks);
    end;
    /
     
     
     
     
     
  • 相关阅读:
    编写便于打印的Shellcode
    DOS路径转化为NT路径
    当你孤单时你会想起谁
    【转载】从文件句柄获得全路径
    C# DLLImport C++ dll 几点注意事项
    充值系统系统异常处理解决方案
    Demo 与实际应用开发之间的距离
    IIS7.0出错的解决方案 IIS 状态代码:IIS详细错误代码以及解释
    log4net 写日志到 Sql server 数据库
    Log4net 的使用及注意事项
  • 原文地址:https://www.cnblogs.com/sky2088/p/13563253.html
Copyright © 2011-2022 走看看