<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Stats collection</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Tue, 18 Jun 2013 17:11:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-42359</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 16:21:41 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-42359</guid>
		<description><![CDATA[A DBA,

No, it&#039;s not necessary.

The best strategy depends on version of Oracle, options licensed, time available, and rate of change.

In 11g I would look at using the default (auto_sample_size) because this allows Oracle to use its new &#039;approximate NDV&#039; to calculate the number of distinct values for each column; however I would disable all histogram collection and write code to generate histograms where I thought it necessary. 

There&#039;s also the question of partitioning - a monolithic table (with indexes) of 1TB is probably not a good thing (nor is 100GB, for that matter), and you should probably looking at partitioned tables and gathering stats only for changed partitions.

The topic is too big for a blog note - but it&#039;s one a talk about in my chapter of &lt;a href=&quot;http://www.amazon.co.uk/Expert-Oracle-Practices-Database-Administration/dp/1430226684/ref=pd_sim_b_7&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;&lt;strong&gt;Expert Oracle Practices&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>A DBA,</p>
<p>No, it&#8217;s not necessary.</p>
<p>The best strategy depends on version of Oracle, options licensed, time available, and rate of change.</p>
<p>In 11g I would look at using the default (auto_sample_size) because this allows Oracle to use its new &#8216;approximate NDV&#8217; to calculate the number of distinct values for each column; however I would disable all histogram collection and write code to generate histograms where I thought it necessary. </p>
<p>There&#8217;s also the question of partitioning &#8211; a monolithic table (with indexes) of 1TB is probably not a good thing (nor is 100GB, for that matter), and you should probably looking at partitioned tables and gathering stats only for changed partitions.</p>
<p>The topic is too big for a blog note &#8211; but it&#8217;s one a talk about in my chapter of <a href="http://www.amazon.co.uk/Expert-Oracle-Practices-Database-Administration/dp/1430226684/ref=pd_sim_b_7" rel="nofollow"><em><strong>Expert Oracle Practices</strong></em></a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A DBA</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-42286</link>
		<dc:creator><![CDATA[A DBA]]></dc:creator>
		<pubDate>Tue, 08 Nov 2011 08:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-42286</guid>
		<description><![CDATA[Dear Sir,
In dbms_stats.gather_table_stats() function, there is a parameter called estimate_percent. It tells oracle to sample that much amount to gather statistics.
We have lots of tables ranging from 100gb to 1 tb size. Weekly we take table stats with estimate_percent=100 and degree=10. The tables are highly DML active so our senior DBA argues that estimate_percent=100 is the best choice as there are lots of deletions/insertions/updations.
But it takes a lot of time to calculate statistics.
Is it really neccessary to estimate_percent to set 100?]]></description>
		<content:encoded><![CDATA[<p>Dear Sir,<br />
In dbms_stats.gather_table_stats() function, there is a parameter called estimate_percent. It tells oracle to sample that much amount to gather statistics.<br />
We have lots of tables ranging from 100gb to 1 tb size. Weekly we take table stats with estimate_percent=100 and degree=10. The tables are highly DML active so our senior DBA argues that estimate_percent=100 is the best choice as there are lots of deletions/insertions/updations.<br />
But it takes a lot of time to calculate statistics.<br />
Is it really neccessary to estimate_percent to set 100?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40380</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 20 Apr 2011 13:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40380</guid>
		<description><![CDATA[Anand,

I think Stefan has probably answered your question correctly.

There is a memory structure (x$) which collects (approximate) information about data changes, and various things flush this in-memory information to the table.  You can flush the information with an explicit call, and there are various routines which do the flush as their first step. Your example probably demonstrates a timing issue about whether or not the flush takes place.

You could always investigate by enabling tracing and seeing what SQL gets generated behind the scenes as you do your tests.]]></description>
		<content:encoded><![CDATA[<p>Anand,</p>
<p>I think Stefan has probably answered your question correctly.</p>
<p>There is a memory structure (x$) which collects (approximate) information about data changes, and various things flush this in-memory information to the table.  You can flush the information with an explicit call, and there are various routines which do the flush as their first step. Your example probably demonstrates a timing issue about whether or not the flush takes place.</p>
<p>You could always investigate by enabling tracing and seeing what SQL gets generated behind the scenes as you do your tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40308</link>
		<dc:creator><![CDATA[Stefan]]></dc:creator>
		<pubDate>Sun, 10 Apr 2011 18:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40308</guid>
		<description><![CDATA[Monitoring Info is not flushed permanently, as can be seen also by selecting from dba_tab_modifications. 
There ist the procedure dbms_stats.flush_database_monitoring_info to flush current info.
Afterward changes are visible.  

Guess: I assume, not tested, upon using the list stale option, this is done internally as well. An this is
the reason why this information is seen after the call.]]></description>
		<content:encoded><![CDATA[<p>Monitoring Info is not flushed permanently, as can be seen also by selecting from dba_tab_modifications.<br />
There ist the procedure dbms_stats.flush_database_monitoring_info to flush current info.<br />
Afterward changes are visible.  </p>
<p>Guess: I assume, not tested, upon using the list stale option, this is done internally as well. An this is<br />
the reason why this information is seen after the call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40243</link>
		<dc:creator><![CDATA[Anand]]></dc:creator>
		<pubDate>Fri, 08 Apr 2011 16:13:56 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40243</guid>
		<description><![CDATA[The database version is 11.2.0.1.0]]></description>
		<content:encoded><![CDATA[<p>The database version is 11.2.0.1.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40242</link>
		<dc:creator><![CDATA[Anand]]></dc:creator>
		<pubDate>Fri, 08 Apr 2011 16:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40242</guid>
		<description><![CDATA[Hi Sir,

I created a partition table (monthly) and inserted rows into it.Gathered the stats of the table using exec dbms_stats.gather_table_stats(&#039;ANAND&#039;,&#039;SALES_PART&#039;);. Then i locked the stats of the table using dbms_stats.lock_table_stats and did  insert into sales_part select * from sales_part where time_id &gt;&#039;01-NOV-10&#039;; which inserted data in December partition.

After doing the insert checked dba_tab_statistics

21:17:31 SQL&gt; select OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION,STATTYPE_LOCKED ,STALE_STATS
21:17:35   2  from dba_tab_statistics
21:17:35   3  where owner =&#039;ANAND&#039;
21:17:36   4  and STATTYPE_LOCKED is not null
21:17:36   5  order by 2
21:17:37   6  /

OWNER                          TABLE_NAME      PARTITION_NAME            PARTITION_POSITION STATT STA
------------------------------ --------------- ------------------------- ------------------ ----- ---
ANAND                          SALES_PART                                                   ALL   NO
ANAND                          SALES_PART      SALE_APR                                   4 ALL   NO
ANAND                          SALES_PART      SALE_AUG                                   8 ALL   NO
ANAND                          SALES_PART      SALE_DEC                                  12 ALL   NO
ANAND                          SALES_PART      SALE_FEB                                   2 ALL   NO
ANAND                          SALES_PART      SALE_JAN                                   1 ALL   NO
ANAND                          SALES_PART      SALE_SEPT                                  9 ALL   NO
ANAND                          SALES_PART      SALE_JUN                                   6 ALL   NO
ANAND                          SALES_PART      SALE_MAY                                   5 ALL   NO
ANAND                          SALES_PART      SALE_MCH                                   3 ALL   NO
ANAND                          SALES_PART      SALE_NOV                                  11 ALL   NO
ANAND                          SALES_PART      SALE_OCT                                  10 ALL   NO
ANAND                          SALES_PART      SALE_JUL                                   7 ALL   NO

So, the STALE_STATS column for SALE_DEC partition shows NO.

Immediately, then i ran 

select * from table(list_stale(&#039;LIST AUTO&#039;));  --&gt; It didn&#039;t list the table/partition name .

After, which dba_tab_statistics started showing  STALE_STATS value as  YES  for SALE_DEC partition.

21:21:24 SQL&gt; select OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION,STATTYPE_LOCKED ,STALE_STATS
21:21:26   2  from dba_tab_statistics
21:21:27   3  where owner =&#039;ANAND&#039;
21:21:27   4  and STATTYPE_LOCKED is not null
21:21:28   5  order by 2
21:21:28   6  /

OWNER                          TABLE_NAME      PARTITION_NAME            PARTITION_POSITION STATT STA
------------------------------ --------------- ------------------------- ------------------ ----- ---
ANAND                          SALES_PART                                                   ALL   YES
ANAND                          SALES_PART      SALE_APR                                   4 ALL   NO
ANAND                          SALES_PART      SALE_AUG                                   8 ALL   NO
ANAND                          SALES_PART      SALE_DEC                                  12 ALL   YES
ANAND                          SALES_PART      SALE_FEB                                   2 ALL   NO
ANAND                          SALES_PART      SALE_JAN                                   1 ALL   NO
ANAND                          SALES_PART      SALE_SEPT                                  9 ALL   NO
ANAND                          SALES_PART      SALE_JUN                                   6 ALL   NO
ANAND                          SALES_PART      SALE_MAY                                   5 ALL   NO
ANAND                          SALES_PART      SALE_MCH                                   3 ALL   NO
ANAND                          SALES_PART      SALE_NOV                                  11 ALL   NO
ANAND                          SALES_PART      SALE_OCT                                  10 ALL   NO
ANAND                          SALES_PART      SALE_JUL                                   7 ALL   NO

Why is it that after running the function   dba_tab_statistics is showing stats as STALE, why not before it?]]></description>
		<content:encoded><![CDATA[<p>Hi Sir,</p>
<p>I created a partition table (monthly) and inserted rows into it.Gathered the stats of the table using exec dbms_stats.gather_table_stats(&#8216;ANAND&#8217;,'SALES_PART&#8217;);. Then i locked the stats of the table using dbms_stats.lock_table_stats and did  insert into sales_part select * from sales_part where time_id &gt;&#8217;01-NOV-10&#8242;; which inserted data in December partition.</p>
<p>After doing the insert checked dba_tab_statistics</p>
<p>21:17:31 SQL&gt; select OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION,STATTYPE_LOCKED ,STALE_STATS<br />
21:17:35   2  from dba_tab_statistics<br />
21:17:35   3  where owner =&#8217;ANAND&#8217;<br />
21:17:36   4  and STATTYPE_LOCKED is not null<br />
21:17:36   5  order by 2<br />
21:17:37   6  /</p>
<p>OWNER                          TABLE_NAME      PARTITION_NAME            PARTITION_POSITION STATT STA<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8211; &#8212;<br />
ANAND                          SALES_PART                                                   ALL   NO<br />
ANAND                          SALES_PART      SALE_APR                                   4 ALL   NO<br />
ANAND                          SALES_PART      SALE_AUG                                   8 ALL   NO<br />
ANAND                          SALES_PART      SALE_DEC                                  12 ALL   NO<br />
ANAND                          SALES_PART      SALE_FEB                                   2 ALL   NO<br />
ANAND                          SALES_PART      SALE_JAN                                   1 ALL   NO<br />
ANAND                          SALES_PART      SALE_SEPT                                  9 ALL   NO<br />
ANAND                          SALES_PART      SALE_JUN                                   6 ALL   NO<br />
ANAND                          SALES_PART      SALE_MAY                                   5 ALL   NO<br />
ANAND                          SALES_PART      SALE_MCH                                   3 ALL   NO<br />
ANAND                          SALES_PART      SALE_NOV                                  11 ALL   NO<br />
ANAND                          SALES_PART      SALE_OCT                                  10 ALL   NO<br />
ANAND                          SALES_PART      SALE_JUL                                   7 ALL   NO</p>
<p>So, the STALE_STATS column for SALE_DEC partition shows NO.</p>
<p>Immediately, then i ran </p>
<p>select * from table(list_stale(&#8216;LIST AUTO&#8217;));  &#8211;&gt; It didn&#8217;t list the table/partition name .</p>
<p>After, which dba_tab_statistics started showing  STALE_STATS value as  YES  for SALE_DEC partition.</p>
<p>21:21:24 SQL&gt; select OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION,STATTYPE_LOCKED ,STALE_STATS<br />
21:21:26   2  from dba_tab_statistics<br />
21:21:27   3  where owner =&#8217;ANAND&#8217;<br />
21:21:27   4  and STATTYPE_LOCKED is not null<br />
21:21:28   5  order by 2<br />
21:21:28   6  /</p>
<p>OWNER                          TABLE_NAME      PARTITION_NAME            PARTITION_POSITION STATT STA<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8211; &#8212;<br />
ANAND                          SALES_PART                                                   ALL   YES<br />
ANAND                          SALES_PART      SALE_APR                                   4 ALL   NO<br />
ANAND                          SALES_PART      SALE_AUG                                   8 ALL   NO<br />
ANAND                          SALES_PART      SALE_DEC                                  12 ALL   YES<br />
ANAND                          SALES_PART      SALE_FEB                                   2 ALL   NO<br />
ANAND                          SALES_PART      SALE_JAN                                   1 ALL   NO<br />
ANAND                          SALES_PART      SALE_SEPT                                  9 ALL   NO<br />
ANAND                          SALES_PART      SALE_JUN                                   6 ALL   NO<br />
ANAND                          SALES_PART      SALE_MAY                                   5 ALL   NO<br />
ANAND                          SALES_PART      SALE_MCH                                   3 ALL   NO<br />
ANAND                          SALES_PART      SALE_NOV                                  11 ALL   NO<br />
ANAND                          SALES_PART      SALE_OCT                                  10 ALL   NO<br />
ANAND                          SALES_PART      SALE_JUL                                   7 ALL   NO</p>
<p>Why is it that after running the function   dba_tab_statistics is showing stats as STALE, why not before it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40209</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 18:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40209</guid>
		<description><![CDATA[Ellis,

Thanks for the link - I hadn&#039;t noticed that post.

Extended stats can be very helpful and I would expect to find a few cases on any site I visit where they could be useful.  However, although I might look at the capturing table and report to see what it said, I don&#039;t think I would let Oracle generate extended stats automatically.

I have the same opinion of virtual columns, by the way.  It&#039;s  another variation on the same theme, of course, but again I would expect to find a few cases on any system where they could be helpful.]]></description>
		<content:encoded><![CDATA[<p>Ellis,</p>
<p>Thanks for the link &#8211; I hadn&#8217;t noticed that post.</p>
<p>Extended stats can be very helpful and I would expect to find a few cases on any site I visit where they could be useful.  However, although I might look at the capturing table and report to see what it said, I don&#8217;t think I would let Oracle generate extended stats automatically.</p>
<p>I have the same opinion of virtual columns, by the way.  It&#8217;s  another variation on the same theme, of course, but again I would expect to find a few cases on any system where they could be helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40208</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 18:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40208</guid>
		<description><![CDATA[Bernard,

Thanks for the correction - now fixed.]]></description>
		<content:encoded><![CDATA[<p>Bernard,</p>
<p>Thanks for the correction &#8211; now fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Polarski</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40204</link>
		<dc:creator><![CDATA[Bernard Polarski]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 09:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40204</guid>
		<description><![CDATA[Typo : &#039;it is mon_mods$&#039;  not mon_mod$. 

SQL&gt; desc mon_mods$
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 OBJ#                                               NUMBER
 INSERTS                                            NUMBER
 UPDATES                                            NUMBER
 DELETES                                            NUMBER
 TIMESTAMP                                          DATE
 FLAGS                                              NUMBER
 DROP_SEGMENTS                                      NUMBER


Please, delete this comment when dequeued end consumed.]]></description>
		<content:encoded><![CDATA[<p>Typo : &#8216;it is mon_mods$&#8217;  not mon_mod$. </p>
<p>SQL&gt; desc mon_mods$<br />
 Name                                      Null?    Type<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 OBJ#                                               NUMBER<br />
 INSERTS                                            NUMBER<br />
 UPDATES                                            NUMBER<br />
 DELETES                                            NUMBER<br />
 TIMESTAMP                                          DATE<br />
 FLAGS                                              NUMBER<br />
 DROP_SEGMENTS                                      NUMBER</p>
<p>Please, delete this comment when dequeued end consumed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ellis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/01/stats-collection/#comment-40193</link>
		<dc:creator><![CDATA[ellis]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 22:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6150#comment-40193</guid>
		<description><![CDATA[As always, great post. 

On a side note, have probably read this but just curious, in terms of stats collection, what your experience has been with &quot;having&quot; to collect extended stats: 

http://blogs.oracle.com/optimizer/2011/03/how_do_i_know_what_extended_statistics_are_needed_for_a_given_workload.html 

Thanks and great post.]]></description>
		<content:encoded><![CDATA[<p>As always, great post. </p>
<p>On a side note, have probably read this but just curious, in terms of stats collection, what your experience has been with &#8220;having&#8221; to collect extended stats: </p>
<p><a href="http://blogs.oracle.com/optimizer/2011/03/how_do_i_know_what_extended_statistics_are_needed_for_a_given_workload.html" rel="nofollow">http://blogs.oracle.com/optimizer/2011/03/how_do_i_know_what_extended_statistics_are_needed_for_a_given_workload.html</a> </p>
<p>Thanks and great post.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
