日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle database 12cr2 使用 dbms_stat 采集统计信息

發布時間:2024/6/30 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle database 12cr2 使用 dbms_stat 采集统计信息 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

dbms_stat 是oracle database 采集統計信息的集成工具。非常方便和高效。

備份

創建stat_table

begindbms_stats.create_stat_table(ownname => 'drp',stattab => 'stat_table') ; end;

導出整個scheme的統計信息

begindbms_stats.export_schema_stats(ownname => 'drp',stattab => 'stat_table') ; end;

分析

begin--固定表的統計信息 sys.dbms_stats.gather_fixed_objects_stats;--數據字典的統計信息 sys.dbms_stats.gather_dictionary_stats;--instance的統計信息 sys.dbms_stats.gather_system_stats(); end;

抽樣分析drp用戶對象

BEGINsys.dbms_stats.gather_schema_stats(ownname=> 'drp' ,estimate_percent=> 50 , cascade=> TRUE,--method_opt=>'for all columns size 1 '--method_opt=>'for all columns size repeat ',method_opt=>'for all indexed columns size skewonly ',degree=>8); END ;

抽樣分析drp.order表

BEGINdbms_stats.gather_table_stats(ownname=> 'drp' ,tabname=> 'order',estimate_percent=> 50 , cascade=> TRUE,--method_opt=>'for all columns size 1 ',--method_opt=>'for all columns size repeat ',method_opt=>'for all indexed columns size skewonly ',no_invalidate=>FALSE,granularity=>'AUTO',degree=>8); END ;

抽樣分析drp.order表的idx_order_x1索引

BEGINsys.dbms_stats.gather_index_stats(ownname=> 'drp' ,indname=>'idx_order_x1',estimate_percent=> 100 ); END ;

method_opt選項
for table–只統計表 
for all indexed columns–只統計有索引的表列
for all indexes–只分析統計相關索引
for all columns

在method_opt子句中,還有一些重要的新選項,包括skewonly,repeat和auto:
method_opt=>’for all columns size 1’
method_opt=>’for all columns size skewonly’
method_opt=>’for all columns size repeat’
method_opt=>’for all columns size auto’

刪除

重新采集后發現效果不好的,可以刪除統計信息

刪除整個schema的統計信息

begindbms_stats.delete_schema_stats(ownname => 'drp') ; end;

刪除表的統計信息

begindbms_stats.delete_table_stats(ownname => 'drp',tabname => 'order') ; end;

導入

導入表的統計信息

begindbms_stats.import_table_stats(ownname => 'drp',tabname => 'order',stattab => 'stat_table') ; end;

導入整個schema的統計信息

begindbms_stats.import_schema_stats(ownname => 'drp',stattab => 'stat_table'); end;

轉載于:https://www.cnblogs.com/ctypyb2002/p/9793016.html

總結

以上是生活随笔為你收集整理的oracle database 12cr2 使用 dbms_stat 采集统计信息的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。