如题:
     现在遇见这样一个问题,因为数据库表多,而且很多arc表,数据量很大。所以我做好策略每天抽样分析一些表,但是有些表在抽样1%分析的时候会报错,而抽样5%又不报错,当然这只是一种情况,还有抽样5%报错,而全表分析不报错。
     全表分析肯定不可行的,因为表有上亿条记录。所以想了解下,oracle对于表分析是通过什么方式计算的,没找到有用的文档,如果哪位有有用的文档也可以共享下,谢谢!

解决方案 »

  1.   


    楼主是怎么分析的?analyze table tablename compute statistics for all indexes;是用这个语句吗?------------------------------------------------------------------------------ 
    Blog: http://blog.csdn.net/tianlesoftware 
    网上资源: http://tianlesoftware.download.csdn.net 
    相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx 
    Q Q 群:62697716
      

  2.   

     Dbms_Stats.Gather_Table_Stats(ownname          => c.tab_Owner,
                                        tabname          => c.Tab_Name,
                                        Estimate_Percent => 5,
                                        Cascade          => True);你说的那个现在已经很少用了吧?我是oracle10g
      

  3.   

    analyze 和Dbms_Stats 各有优点。 Use the ANALYZE statement (rather than DBMS_STATS) for statistics collection not related to the cost-based optimizer :Analyze Statement
    The ANALYZE statement can be used to gather statistics for a specific table, index or cluster. The statistics can be computed exactly, or estimated based on a specific number of rows, or a percentage of rows:DBMS_STATS
    The DBMS_STATS package was introduced in Oracle 8i and is Oracles preferred method of gathering object statistics. 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:设为1的时候报的是什么错的?------------------------------------------------------------------------------ 
    Blog: http://blog.csdn.net/tianlesoftware 
    网上资源: http://tianlesoftware.download.csdn.net 
    相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx 
    Q Q 群:62697716
      

  4.   

        恩,是各有优点,因为分区表多,所以还是用DBMS_STATS ,而且oracle也已经不维护Analyze Statement了,呵呵。
        我报错的情况是,报表里明明有的一个字段,分析的时候却报ORA-00904,碰到3个表,有2个表是报的主键,有一个表报的是很平常的字段,不是索引也不是主键。补充:这3张表都是一级分区表!
      

  5.   


    ORA-00904: string: invalid identifier 
    Cause: The column name entered is either missing or invalid. 
    Action: Enter a valid column name. A valid column name must begin with a letter, be less than or equal to 30 characters, and consist of only alphanumeric characters and the special characters $, _, and #. If it contains other characters, then it must be enclosed in double quotation s. It may not be a reserved word.  看看字段名先.. 还有其他的错误吗?------------------------------------------------------------------------------ 
    Blog: http://blog.csdn.net/tianlesoftware 
    网上资源: http://tianlesoftware.download.csdn.net 
    相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx 
    Q Q 群:62697716
      

  6.   

       错误我肯定是知道是什么问题的,就是因为字段名确实没错,而且我是从dba_tables里面取的owner 和 table_name ,那么分析的时候他应该自己去查表的结构啊。为什么会出现这个错,而且还是在按某一个比例分析的时候才出现呢? 就是因为这个很疑惑,所以才想要了解oracle在分析时到底是怎么计算的!
      

  7.   

    设置跟踪吧,看出错的时候的trace文件提示在查询什么字典表