Oracle效能-查詢統計資訊的SQL語句

來源:互聯網
上載者:User

1、查詢表的統計資訊
SELECT A.TABLE_NAME,
       A.NUM_ROWS,
       A.BLOCKS,
       A.EMPTY_BLOCKS,
       A.AVG_SPACE,
       A.CHAIN_CNT,
       A.AVG_ROW_LEN,
       A.GLOBAL_STATS,
       A.USER_STATS,
       A.SAMPLE_SIZE,
       TO_CHAR(A.LAST_ANALYZED, 'YYYY-MM-DD HH24:MI:SS')
  FROM DBA_TABLES A
 WHERE OWNER = UPPER(NVL('&OWNER', USER))
   AND TABLE_NAME = UPPER('&TABLE_NAME');

2、查詢列的統計資訊
SELECT T.COLUMN_NAME,
       T.DATA_TYPE,
       T.NULLABLE,
       T.NUM_DISTINCT,
       T.density,
       T.NUM_BUCKETS,
       T.NUM_NULLS,
       T.GLOBAL_STATS,
       T.USER_STATS,
       T.sample_size,
       TO_CHAR(T.LAST_ANALYZED, 'YYYY-MM-DD HH24:MI:SS')
  FROM DBA_TAB_COLS T
 WHERE TABLE_NAME = UPPER('&TABLE_NAME')
   AND OWNER = UPPER(NVL('&OWNER', USER));

3、查詢索引的統計資訊
SELECT T.INDEX_NAME,
       T.UNIQUENESS,
       T.BLEVEL,
       T.LEAF_BLOCKS,
       T.DISTINCT_KEYS,
       T.NUM_ROWS,
       T.AVG_LEAF_BLOCKS_PER_KEY,
       T.AVG_DATA_BLOCKS_PER_KEY,
       T.CLUSTERING_FACTOR,
       T.GLOBAL_STATS,
       T.USER_STATS,
       T.SAMPLE_SIZE,
       TO_CHAR(T.LAST_ANALYZED, 'YYYY-MM-DD HH24:MI:SS')
  FROM DBA_INDEXES T
 WHERE TABLE_NAME = UPPER('&TABLE_NAME')
   AND OWNER = UPPER(NVL('&OWNER', USER));

 

 

4.查看收集統計資訊的Job
    select log_date,job_name,status 
    from dba_scheduler_job_run_details
    where job_name='GATHER_STATS_JOB' order by log_id;

    select * from dba_scheduler_programs
    where program_name=upper('GATHER_STATS_PROG');
   Select dbms_stats.get_stats_history_availability from dual;

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.