<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  回復(fù)  更多評(píng)論   

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

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 噜噜嘿在线视频免费观看| 国产h视频在线观看网站免费| 日本一道在线日本一道高清不卡免费| 亚洲精品欧洲精品| 久久久久久国产精品免费免费男同 | 色婷婷7777免费视频在线观看| 午夜影视日本亚洲欧洲精品一区 | 免费精品99久久国产综合精品| 国产精品亚洲综合专区片高清久久久| 成a人片亚洲日本久久| 免费jjzz在在线播放国产| 麻豆亚洲AV成人无码久久精品 | 在线观看免费精品国产| 亚洲AV无码国产剧情| www国产亚洲精品久久久| 一级毛片在线完整免费观看| 久久久久亚洲精品男人的天堂| 中文永久免费观看网站| 亚洲国产精品VA在线观看麻豆| 午夜视频在线免费观看| 亚洲精品偷拍无码不卡av| 成人无码区免费视频观看| 精品亚洲视频在线| 国产成人A亚洲精V品无码| 香蕉成人免费看片视频app下载| 亚洲成人中文字幕| 久久精品女人天堂AV免费观看| 美女被免费网站在线视频免费| 亚洲中文字幕在线观看| 最近2022中文字幕免费视频| 亚洲国产日韩综合久久精品| 国产视频精品免费| 在线观看免费视频网站色| 久久精品亚洲一区二区三区浴池| 在线视频观看免费视频18| 国产精品亚洲精品日韩动图 | 国产亚洲精品无码拍拍拍色欲| 久久久久久AV无码免费网站 | 日韩精品视频在线观看免费| 国产V亚洲V天堂无码久久久| 一级女人18毛片免费|