<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Neil的備忘錄

    just do it
    posts - 66, comments - 8, trackbacks - 0, articles - 0

    Create statistics

    Since Oracle 8i the Cost Based Optimizer (CBO) is the preferred optimizer for Oracle.
    In order to make good use of the CBO, you need to create statistics for the data in the database. There are several options to create statistics.

    Analyze command

    The ANALYZE command is available for all versions of Oracle, however to obtain faster and better statistics use the procedures supplied - in 7.3.4 and 8.0 DBMS_UTILITY.ANALYZE_SCHEMA,
    and in 8i and above - DBMS_STATS.GATHER_SCHEMA_STATS The analyze table can be used to create statistics for 1 table, index or cluster.
    Syntax:
    ANALYZE table tableName {compute|estimate|delete) statistics options
    ANALYZE table indexName {compute|estimate|delete) statistics options
    ANALYZE cluster clusterName {compute|estimate|delete) statistics options

    Code examples 

    ANALYZE table scott compute statistics;
    ANALYZE table scott estimate statistics sample 25 percent;
    ANALYZE table scott estimate statistics sample 1000 rows;
    analyze index sc_idx compute statistics;
    analyze index sc_idx validate structure;

    DBMS_UTILITY.ANALYZE_SCHEMA

    With DBMS_UTILITY.ANALYZE_SCHEMA you can gather all the statistics for all the tables, clusters and indexes of a schema.
    Code examples
    exec DBMS_UTILITY.ANALYZE_SCHEMA('SCOTT','COMPUTE');
    exec DBMS_UTILITY.ANALYZE_SCHEMA('SCOTT','ESTIMATE', estimate_rows =>
    1000);
    exec DBMS_UTILITY.ANALYZE_SCHEMA('SCOTT','ESTIMATE', estimate_percent
    => 25);
    exec DBMS_UTILITY.ANALYZE_SCHEMA('SCOTT','DELETE');
    Note: It's also possible to analyze the whole database with the DBMS_UTILITY.ANALYZE_DATABASE('COMPUTE'); command.

    DBMS_STATS.GATHER_SCHEMA_STATS

    From Oracle 8i the DBMS_STATS package is the preferred method Oracle list a number of benefits to using it including parallel execution, long term storage of statistics and transfer of statistics between servers. Once again, it follows a similar format to the other methods:
    Syntax:
    exec DBMS_STATS.GATHER_SCHEMA_STATS(ownname,estimate_percent, block_sample , method_opt,degree,granularity,cascade,stattab, statid,options,statown ,no_invalidate, gather_temp,gather_fixed);
    Code examples:

    exec
    DBMS_STATS.GATHER_SCHEMA_STATS('SCOTT',DBMS_STATS.AUTO_SAMPLE_SIZE);
    exec
    DBMS_STATS.GATHER_SCHEMA_STATS(ownname=>'SCOTT'
    ,estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE);
    EXEC DBMS_STATS.gather_schema_stats(ownname => 'SCOTT',
    estimate_percent => 25);
    EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');
    EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK');

    exec DBMS_STATS.DELETE_SCHEMA_STATS('SCOTT');

    Note: It's also possible to gather statistics for the whole database with the DBMS_STATS.gather_database_stats; command.

    Transfering statistics between database.

    It can be very handy to use production statistics on your development database, so that you can forecast the optimizer behavior.

    You can do this the following way:

    1. Create the statistics table.
    exec DBMS_STATS.CREATE_STAT_TABLE(ownname =>'SCHEMA_NAME' ,stat_tab => 'STATS_TABLE' , tblspace => 'STATS_TABLESPACE');
    Example:
    exec DBMS_STATS.CREATE_STAT_TABLE(ownname =>'SYSTEM',stat_tab => 'STATS_TABLE');

    2. Export statistics to statistics table
    EXEC DBMS_STATS.EXPORT_SCHEMA_STATS('ORIGINAL_SCHEMA' ,'STATS_TABLE',NULL,'SYSTEM');

    3. Import statistics into the data dictionary.
    exec DBMS_STATS.IMPORT_SCHEMA_STATS('NEW_SCHEMA','STATS_TABLE',NULL,'SYSTEM');

    4. Drop the statistics table.
    exec DBMS_STATS.DROP_STAT_TABLE('SYSTEM','STATS_TABLE');

    原文地址: http://www.oradev.com/create_statistics.jsp

    Feedback

    # re: Create statistics for the oracle cost based optimizer  回復  更多評論   

    2009-01-16 11:13 by Neil's NoteBook
    wow , super power !

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲无人区午夜福利码高清完整版| 永久免费AV无码国产网站| 四虎AV永久在线精品免费观看| 亚洲av乱码一区二区三区| 中文免费观看视频网站| 亚洲二区在线视频| 成人超污免费网站在线看| 亚洲AV无码一区二区一二区| 免费无码成人AV片在线在线播放| 亚洲精华国产精华精华液| 日韩一区二区三区免费体验| 色天使色婷婷在线影院亚洲| 免费人成网站7777视频| 猫咪www免费人成网站| 亚洲色大成网站www永久一区| 毛片在线全部免费观看| 亚洲同性男gay网站在线观看| 日韩精品成人无码专区免费| 亚洲AV无码一区二区乱子仑| 久久亚洲国产成人精品无码区| 亚洲免费观看视频| 精品亚洲AV无码一区二区| 日本免费人成黄页网观看视频 | 亚洲国产区男人本色在线观看| 成年人视频在线观看免费 | XXX2高清在线观看免费视频| 亚洲AV日韩AV永久无码免下载| 波多野结衣免费在线观看| 久久精品国产亚洲AV未满十八| 中文字幕亚洲乱码熟女一区二区| 嫩草在线视频www免费观看| 亚洲熟女www一区二区三区| 久久乐国产精品亚洲综合| 国产曰批免费视频播放免费s| 亚洲av午夜电影在线观看| 亚洲午夜久久久影院| 一色屋成人免费精品网站| 无码AV动漫精品一区二区免费| 亚洲AV无码AV男人的天堂| 日韩视频在线免费| 在线涩涩免费观看国产精品|