ITPub博客

首页 > Linux操作系统 > Linux操作系统 > analyze与dbms_stat逻辑读对比测试

analyze与dbms_stat逻辑读对比测试

原创 Linux操作系统 作者:lsq_008 时间:2008-07-15 15:47:26 0 删除 编辑

1. analyze

SQL> select segment_name,owner,segment_type,tablespace_name,bytes/1024/1024 from dba_segments where tablespace_name='TEST';
 
 
SEGMENT_NAME                   OWNER                          SEGMENT_TYPE       TABLESPACE BYTES/1024/1024
------------------------------ ------------------------------ ------------------ ---------- ---------------
TEST                           SYS                            TABLE PARTITION    TEST                   144
TEST                           SYS                            TABLE PARTITION    TEST                   144
TEST                           SYS                            TABLE PARTITION    TEST                   136
TEST                           SYS                            TABLE PARTITION    TEST                    72
 
SQL> select * from v$mystat  where STATISTIC#=9;
 
       SID STATISTIC#      VALUE
---------- ---------- ----------
        10          9     102842
 
SQL> analyze table test compute statistics;
 
Table analyzed.
 
SQL> select * from v$mystat  where STATISTIC#=9;
 
       SID STATISTIC#      VALUE
---------- ---------- ----------
        10          9     139314
 
SQL> analyze table test delete  statistics;
 
Table analyzed.
 
SQL> select 139314-102842 from dual;
 
139314-102842
-------------
       
36472

2. dbms_stats

SQL>  select * from v$mystat  where STATISTIC#=9;
 
       SID STATISTIC#      VALUE
---------- ---------- ----------
        15          9       1196
 
SQL> exec dbms_stats.gather_table_stats(user,'test',cascade=>true);
 
PL/SQL procedure successfully completed.
 
SQL> select * from v$mystat  where STATISTIC#=9;
 
       SID STATISTIC#      VALUE
---------- ---------- ----------
        15          9      75250
 
SQL> select 75250-1192 from dual;
 
75250-1192
----------
 
    74058

       可见,对于分区表的分析,用dbms_stats来分析,要比analyze要消耗更多的系统资源,这是因为dbms_stats分析更加准确,包括了对partition的分析,这是要付出代价的。呵呵

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-401674/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 一个监控脚本
请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369151