title: What does it mean when last_analyzed and stale_stats is null
body: <p>We are currently running Oracle 11g and I am looking into if we need to run statistics after a large import.  We have statistics_level set to 'TYPICAL'.  Based on this I'm thinking that we do NOT need to update statistics:  </p>
  
  <blockquote>
    <p>Starting with Oracle Database 11g, the MONITORING and NOMONITORING
    keywords have been deprecated and statistics are collected
    automatically.</p>
  </blockquote>
  
  <p><a href="https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables005.htm" rel="nofollow">https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables005.htm</a>  </p>
  
  <p>However, after creating my database and running my modest import (100's of thousands to millions of records in a handful of tables and the creation of a number of indexes) all of the tables affected by the import show null for last_analyzed and stale_stats using the query below. </p>
  
  <pre><code>select 
      table_name, 
      stale_stats, 
      last_analyzed
  from 
      dba_tab_statistics
   where 
      owner = 'MY_SCHEMA'
  order by 
      last_analyzed desc, table_name asc
  ;
  </code></pre>
  
  <p>Should I expect certain queries to have poor performance in this state?</p>
  
  <p>Should I expect the statistics to eventually run and last_analyzed and stale_stats to eventually be populated (the documentation suggests that these values are updated about every three hours by default)?  </p>
  
  <p>It has been my experience that for moderately sized databases (tables with millions of records and less than 10's of millions of records) that mucking around with stats is not necessary and generally causes more problems than it solves. Is this generally the case?  </p>
  
  <p><strong>* * * NOTES ON OUR RESOLUTION * * *</strong></p>
  
  <p>We were using this:</p>
  
  <pre><code>analyze table my_table compute statistics
  </code></pre>
  
  <p>We switched to this:</p>
  
  <pre><code>dbms_stats.gather_table_stats('MY_SCHEMA', 'MY_TABLE');
  </code></pre>
  
  <p>The analyze table statement took about 1:30 minutes in one environment and about 15:00 - 20:00 minutes in the second environment.  </p>
  
  <p>The gather_table_stats statement took about 0:30 to 1:00 minutes in both of the two instances we were able to examine.  </p>
  
  <p>Our plan moving forward is to switch our analyze table statements to gather_table_stats calls.  </p>