<?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/"
		>
<channel>
	<title>Comments on: DBMS_STATS, METHOD_OPT and FOR ALL INDEXED COLUMNS</title>
	<atom:link href="http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/feed/" rel="self" type="application/rss+xml" />
	<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/</link>
	<description>Oracle Database Performance And Scalability Blog</description>
	<lastBuildDate>Mon, 01 Mar 2010 22:11:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: 2009 Year-End Zeitgeist</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-11060</link>
		<dc:creator>2009 Year-End Zeitgeist</dc:creator>
		<pubDate>Mon, 04 Jan 2010 00:09:50 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-11060</guid>
		<description>[...] DBMS_STATS, METHOD_OPT and FOR ALL INDEXED COLUMNS [...]</description>
		<content:encoded><![CDATA[<p>[...] DBMS_STATS, METHOD_OPT and FOR ALL INDEXED COLUMNS [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-313</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Thu, 20 Aug 2009 08:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-313</guid>
		<description>&lt;a href=&quot;#comment-9755&quot; rel=&quot;nofollow&quot;&gt;@Henry&lt;/a&gt;

Dynamic sampling is not used when a statement contains bind values, only when the statement contains literals.  This would explain why it makes no difference with ACS.  OTN has a discussion that might be worth reading: http://forums.oracle.com/forums/thread.jspa?threadID=927493&amp;tstart=-1</description>
		<content:encoded><![CDATA[<p><a href="#comment-9755" rel="nofollow">@Henry</a></p>
<p>Dynamic sampling is not used when a statement contains bind values, only when the statement contains literals.  This would explain why it makes no difference with ACS.  OTN has a discussion that might be worth reading: <a href="http://forums.oracle.com/forums/thread.jspa?threadID=927493&#038;tstart=-1" rel="nofollow">http://forums.oracle.com/forums/thread.jspa?threadID=927493&#038;tstart=-1</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henry</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-314</link>
		<dc:creator>Henry</dc:creator>
		<pubDate>Thu, 20 Aug 2009 07:49:48 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-314</guid>
		<description>Thanks for the reminder on col_usage$, I forgot all about that.

I understand that if a new value for a bind variable leads to degraded performance, ACS will (after the second run) lead to a new child cursor and potentially new execution plan. A better plan would be possible only with a histogram present.

I was wondering about dynamic sampling. A new bind value will still degrade performance, which can lead to a new parse/plan via ACS. Even with no histograms (no stats) dynamic sampling could yield a new plan as the skew can be determined. My initial tests show this doesn&#039;t happen and dynamic sampling doesn&#039;t yield a new plan, even with skewed data, using ACS. Testing is still incomplete.</description>
		<content:encoded><![CDATA[<p>Thanks for the reminder on col_usage$, I forgot all about that.</p>
<p>I understand that if a new value for a bind variable leads to degraded performance, ACS will (after the second run) lead to a new child cursor and potentially new execution plan. A better plan would be possible only with a histogram present.</p>
<p>I was wondering about dynamic sampling. A new bind value will still degrade performance, which can lead to a new parse/plan via ACS. Even with no histograms (no stats) dynamic sampling could yield a new plan as the skew can be determined. My initial tests show this doesn&#8217;t happen and dynamic sampling doesn&#8217;t yield a new plan, even with skewed data, using ACS. Testing is still incomplete.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-312</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Wed, 19 Aug 2009 21:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-312</guid>
		<description>&lt;a href=&quot;#comment-9748&quot; rel=&quot;nofollow&quot;&gt;@Henry&lt;/a&gt;

The reason that histograms were gathered in the &quot;Take 2&quot; version and not in the first collection is that sys.col_usage$ has been populated because I ran 3 queries against the table T1.  In the first collection, no queries had been run against T1 so it was impossible for &quot;size auto&quot; to collect any histograms as sys.col_usage$ contained no rows for T1.  This is something to be very mindful of; &lt;strong&gt;if you are using the default method_opt, the predicates in the queries executed against the tables can trigger new histograms to be collected.&lt;/strong&gt;

You can use this query to look at sys.col_usage$
&lt;pre&gt;
select	oo.name owner,
	o.name table_name,
	c.name column_name,
	u.equality_preds,
	u.equijoin_preds,
	u.nonequijoin_preds,
	u.range_preds,
	u.like_preds,
	u.null_preds,
	u.timestamp
from	sys.col_usage$ u,
	sys.obj$ o,
	sys.user$ oo,
	sys.col$ c
where	o.obj#   = u.obj#
and	oo.user# = o.owner#
and	c.obj#   = u.obj#
and	c.col#   = u.intcol#;
&lt;/pre&gt;

If there are no histograms then Adaptive Cursor Sharing will not really change anything.  Adaptive Cursor Sharing was designed for the situation where you have a statement with bind variables and histograms exist on the table.  Adaptive Cursor Sharing is designed to give a new child cursor and plan if the combination of the histogram and peeked predicate value would give a new plan had it been a literal value.</description>
		<content:encoded><![CDATA[<p><a href="#comment-9748" rel="nofollow">@Henry</a></p>
<p>The reason that histograms were gathered in the &#8220;Take 2&#8243; version and not in the first collection is that sys.col_usage$ has been populated because I ran 3 queries against the table T1.  In the first collection, no queries had been run against T1 so it was impossible for &#8220;size auto&#8221; to collect any histograms as sys.col_usage$ contained no rows for T1.  This is something to be very mindful of; <strong>if you are using the default method_opt, the predicates in the queries executed against the tables can trigger new histograms to be collected.</strong></p>
<p>You can use this query to look at sys.col_usage$</p>
<pre>
select	oo.name owner,
	o.name table_name,
	c.name column_name,
	u.equality_preds,
	u.equijoin_preds,
	u.nonequijoin_preds,
	u.range_preds,
	u.like_preds,
	u.null_preds,
	u.timestamp
from	sys.col_usage$ u,
	sys.obj$ o,
	sys.user$ oo,
	sys.col$ c
where	o.obj#   = u.obj#
and	oo.user# = o.owner#
and	c.obj#   = u.obj#
and	c.col#   = u.intcol#;
</pre>
<p>If there are no histograms then Adaptive Cursor Sharing will not really change anything.  Adaptive Cursor Sharing was designed for the situation where you have a statement with bind variables and histograms exist on the table.  Adaptive Cursor Sharing is designed to give a new child cursor and plan if the combination of the histogram and peeked predicate value would give a new plan had it been a literal value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henry</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-311</link>
		<dc:creator>Henry</dc:creator>
		<pubDate>Wed, 19 Aug 2009 20:17:33 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-311</guid>
		<description>While referring back to this article for the umpteenth time, I just noticed one minor(?) discrepancy. I actually noticed it because I was trying to set up my own test case. The first time you gather stats (method_opt is the default), there are no histograms created. When you gather stats at the beginning of &#039;Take 2&#039;, using the same parameters (except for degree=&gt;8 and the unique index already in place, neither of which make a difference), you see histograms.

What&#039;s up with that?

I was looking at Adaptive Cursor Sharing with Dynamic Sampling and was wondering if having method_opt automatically detect skew might be related to dynamic sampling detecting skew, which might affect ACS (when I had no histograms with the default method_opt, dynamic sampling (level 4) didn&#039;t take advantage of ACS).</description>
		<content:encoded><![CDATA[<p>While referring back to this article for the umpteenth time, I just noticed one minor(?) discrepancy. I actually noticed it because I was trying to set up my own test case. The first time you gather stats (method_opt is the default), there are no histograms created. When you gather stats at the beginning of &#8216;Take 2&#8242;, using the same parameters (except for degree=&gt;8 and the unique index already in place, neither of which make a difference), you see histograms.</p>
<p>What&#8217;s up with that?</p>
<p>I was looking at Adaptive Cursor Sharing with Dynamic Sampling and was wondering if having method_opt automatically detect skew might be related to dynamic sampling detecting skew, which might affect ACS (when I had no histograms with the default method_opt, dynamic sampling (level 4) didn&#8217;t take advantage of ACS).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-308</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Wed, 20 May 2009 21:52:57 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-308</guid>
		<description>&lt;a href=&quot;#comment-8828&quot; rel=&quot;nofollow&quot;&gt;@devinder&lt;/a&gt;
What exactly don&#039;t you agree with?

You should recognize the examples are not about full table scan or not.  They are about getting accurate cardinality estimates.  I prefer to have a histogram on a skewed column regardless if it participates in an index or not.  See, indexes are used as a access method, not a way to calculate cardinality (other than a couple exceptions).

There are many, many data warehouses that run queries against tables with million or billions of rows without indexes on the predicate columns and possibly many of those unindexed columns have histograms if skew is present.  Recognize this discussion is not about gathering histograms (or not) on columns which are indexed. It is about gathering column statistics for columns that do not participate in indexes.  Not to be too critical, but 10g has been out for over 5 years now, and 11g for over 1 year, so I&#039;m not sure the weight a pre-10g argument contains these days, especially when issues have been fixed.

If you would be so kind as to cite what Metalink notes make such suggestions, it would be appreciated.</description>
		<content:encoded><![CDATA[<p><a href="#comment-8828" rel="nofollow">@devinder</a><br />
What exactly don&#8217;t you agree with?</p>
<p>You should recognize the examples are not about full table scan or not.  They are about getting accurate cardinality estimates.  I prefer to have a histogram on a skewed column regardless if it participates in an index or not.  See, indexes are used as a access method, not a way to calculate cardinality (other than a couple exceptions).</p>
<p>There are many, many data warehouses that run queries against tables with million or billions of rows without indexes on the predicate columns and possibly many of those unindexed columns have histograms if skew is present.  Recognize this discussion is not about gathering histograms (or not) on columns which are indexed. It is about gathering column statistics for columns that do not participate in indexes.  Not to be too critical, but 10g has been out for over 5 years now, and 11g for over 1 year, so I&#8217;m not sure the weight a pre-10g argument contains these days, especially when issues have been fixed.</p>
<p>If you would be so kind as to cite what Metalink notes make such suggestions, it would be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: devinder</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-307</link>
		<dc:creator>devinder</dc:creator>
		<pubDate>Wed, 20 May 2009 20:40:43 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-307</guid>
		<description>somehow i dont agree with you, why would you run a select against a table with millions of rows and no index on the column in where clause. Its going to do a full table scan anyway, whether histograms are available or not. Histograms are not cheap to come by at least till 10g. Wont you prefer to have histograms on indexed columns and then you know the skewness of the data in the indexed columns and thus help optimizer generate an optimal plan.
the option method_opt=&gt;&#039;for all columns size whatever&#039; not only takes a long time to generate stats on the columns at the same time it generates sub optimal plans, and there are many articles on metalink which suggest not to use this option..</description>
		<content:encoded><![CDATA[<p>somehow i dont agree with you, why would you run a select against a table with millions of rows and no index on the column in where clause. Its going to do a full table scan anyway, whether histograms are available or not. Histograms are not cheap to come by at least till 10g. Wont you prefer to have histograms on indexed columns and then you know the skewness of the data in the indexed columns and thus help optimizer generate an optimal plan.<br />
the option method_opt=&gt;&#8217;for all columns size whatever&#8217; not only takes a long time to generate stats on the columns at the same time it generates sub optimal plans, and there are many articles on metalink which suggest not to use this option..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-310</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Tue, 05 May 2009 18:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-310</guid>
		<description>&lt;a href=&quot;#comment-8795&quot; rel=&quot;nofollow&quot;&gt;@John&lt;/a&gt;
In 9i METHOD_OPT defaults to &#039;FOR ALL COLUMNS SIZE 1&#039;.
In 10g and newer METHOD_OPT defaults to &#039;FOR ALL COLUMNS SIZE AUTO&#039;.
When you don&#039;t explicitly cite it in the DBMS_STATS call, it defaults to one of the above.</description>
		<content:encoded><![CDATA[<p><a href="#comment-8795" rel="nofollow">@John</a><br />
In 9i METHOD_OPT defaults to &#8216;FOR ALL COLUMNS SIZE 1&#8242;.<br />
In 10g and newer METHOD_OPT defaults to &#8216;FOR ALL COLUMNS SIZE AUTO&#8217;.<br />
When you don&#8217;t explicitly cite it in the DBMS_STATS call, it defaults to one of the above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-309</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 05 May 2009 18:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-309</guid>
		<description>how does using &quot;FOR ALL COLUMNS SIZE 1&quot; compare to not using any method_opt?</description>
		<content:encoded><![CDATA[<p>how does using &#8220;FOR ALL COLUMNS SIZE 1&#8243; compare to not using any method_opt?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/comment-page-1/#comment-292</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Thu, 19 Feb 2009 20:52:08 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/?p=190#comment-292</guid>
		<description>&lt;a href=&quot;#comment-6574&quot; rel=&quot;nofollow&quot;&gt;@Kumar&lt;/a&gt;
&lt;blockquote cite=&quot;#commentbody-6574&quot;&gt;
So I have this query which was taking a long time to complete according to developers and I put the hint to do a FTS and it completes in 22 minutes as opposed to 2.5 hrs. I want to remove the hint and tune it the right way and was thinking about creating histograms based on the skewness.
&lt;/blockquote&gt;

With the information provided thus far, I&#039;m not convinced that a histogram is the solution as I am unclear where the problem specifically lies.  Do you have evidence that a predicate column (join or filter) has significant skew and the cardinality estimate is too low in this case?  Have you simplified this down to a specific table and column?  If not, that is ok, but we&#039;ll need to get there to correctly solve this issue.</description>
		<content:encoded><![CDATA[<p><a href="#comment-6574" rel="nofollow">@Kumar</a></p>
<blockquote cite="#commentbody-6574"><p>
So I have this query which was taking a long time to complete according to developers and I put the hint to do a FTS and it completes in 22 minutes as opposed to 2.5 hrs. I want to remove the hint and tune it the right way and was thinking about creating histograms based on the skewness.
</p></blockquote>
<p>With the information provided thus far, I&#8217;m not convinced that a histogram is the solution as I am unclear where the problem specifically lies.  Do you have evidence that a predicate column (join or filter) has significant skew and the cardinality estimate is too low in this case?  Have you simplified this down to a specific table and column?  If not, that is ok, but we&#8217;ll need to get there to correctly solve this issue.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
