<?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: fast refresh of join-only MVs: _mv_refresh_use_stats and locking log stats</title>
	<atom:link href="http://www.adellera.it/blog/2010/03/11/fast-refresh-of-join-only-mvs-_mv_refresh_use_stats-and-locking-log-stats/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adellera.it/blog/2010/03/11/fast-refresh-of-join-only-mvs-_mv_refresh_use_stats-and-locking-log-stats/</link>
	<description>A blog about Oracle - Un blog riguardo Oracle</description>
	<lastBuildDate>Mon, 14 Nov 2011 11:12:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: FAST REFRESH w widokach zmaterializowanych &#8211; nie taki szybki ?! &#171; Okiem bazodanowca</title>
		<link>http://www.adellera.it/blog/2010/03/11/fast-refresh-of-join-only-mvs-_mv_refresh_use_stats-and-locking-log-stats/comment-page-1/#comment-478</link>
		<dc:creator>FAST REFRESH w widokach zmaterializowanych &#8211; nie taki szybki ?! &#171; Okiem bazodanowca</dc:creator>
		<pubDate>Sat, 07 May 2011 13:36:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=426#comment-478</guid>
		<description>[...] Rozwiązanie problemu jest bardzo ładnie przedstawione na blogu Alberto Dell&#8217;Ery :  problem wolnego FAST REFRESH rozwiązany przez Alberto Pierwsza rzecz, która rzuca się w oczy &#8211; problem dotyczy tylko niektórych wersji Oracla. [...]</description>
		<content:encoded><![CDATA[<p>[...] Rozwiązanie problemu jest bardzo ładnie przedstawione na blogu Alberto Dell&#8217;Ery :  problem wolnego FAST REFRESH rozwiązany przez Alberto Pierwsza rzecz, która rzuca się w oczy &#8211; problem dotyczy tylko niektórych wersji Oracla. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan Marston</title>
		<link>http://www.adellera.it/blog/2010/03/11/fast-refresh-of-join-only-mvs-_mv_refresh_use_stats-and-locking-log-stats/comment-page-1/#comment-466</link>
		<dc:creator>Nathan Marston</dc:creator>
		<pubDate>Wed, 05 Jan 2011 07:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=426#comment-466</guid>
		<description>I ran a few followup tests to your article, as I was seeing similar issues with join-only fast refresh MVs containing outer joins.

(FYI, my tests were run on a Linux 2-node RAC running Oracle 11g).

It turns out that once you start using outer joins, only one of the two solutions provided in your article will remove the dreaded HASH_SJ hints from all queries generated by Oracle to perform the MV refresh.

The reason outer joins complicates things is the DML issued by Oracle to do the refresh changes when there&#039;s an outer join in the picture - in my tests, after some base table changes it actually issued an UPDATE against the MV which set the fields from the &quot;outer&quot; table to NULL. I couldn&#039;t tell from tkprof&#039;s output, but I&#039;d guess that query would be issued in response to deleting a row from the table on the outer table.

Even with locked stats on the MV logs (which is the solution I wish worked all the time), that query still contained a HASH_SJ hint.

When I switched to setting &quot;_mv_refresh_use_stats&quot; instead, I found performance improved and the HASH_SJ hint no longer appeared in the refresh queries.

I can&#039;t see a good reason for *any* of the hints in those generated queries. Adding join and table access hints are almost always a bad idea - you&#039;re essentially saying you know something about the data that the CBO doesn&#039;t. 

In the case of MV logs that might be true - the number of rows in the MV log from refresh to refresh could vary a lot. If stats say MV log is small but it&#039;s actually big, the CBO won&#039;t generate the execution plan we want.

I can think of two responses to that argument:
1. Is a fast refresh MV really the appropriate tool if you have that much base table data changing? Why not refresh more frequently (to reduce the number of changes per refresh), or use full refreshes, or use something other than a MV?
2. If you really want to cater for both small and large MV logs, why not perform dynamic sampling on the MV logs and let the CBO do its job?</description>
		<content:encoded><![CDATA[<p>I ran a few followup tests to your article, as I was seeing similar issues with join-only fast refresh MVs containing outer joins.</p>
<p>(FYI, my tests were run on a Linux 2-node RAC running Oracle 11g).</p>
<p>It turns out that once you start using outer joins, only one of the two solutions provided in your article will remove the dreaded HASH_SJ hints from all queries generated by Oracle to perform the MV refresh.</p>
<p>The reason outer joins complicates things is the DML issued by Oracle to do the refresh changes when there&#8217;s an outer join in the picture &#8211; in my tests, after some base table changes it actually issued an UPDATE against the MV which set the fields from the &#8220;outer&#8221; table to NULL. I couldn&#8217;t tell from tkprof&#8217;s output, but I&#8217;d guess that query would be issued in response to deleting a row from the table on the outer table.</p>
<p>Even with locked stats on the MV logs (which is the solution I wish worked all the time), that query still contained a HASH_SJ hint.</p>
<p>When I switched to setting &#8220;_mv_refresh_use_stats&#8221; instead, I found performance improved and the HASH_SJ hint no longer appeared in the refresh queries.</p>
<p>I can&#8217;t see a good reason for *any* of the hints in those generated queries. Adding join and table access hints are almost always a bad idea &#8211; you&#8217;re essentially saying you know something about the data that the CBO doesn&#8217;t. </p>
<p>In the case of MV logs that might be true &#8211; the number of rows in the MV log from refresh to refresh could vary a lot. If stats say MV log is small but it&#8217;s actually big, the CBO won&#8217;t generate the execution plan we want.</p>
<p>I can think of two responses to that argument:<br />
1. Is a fast refresh MV really the appropriate tool if you have that much base table data changing? Why not refresh more frequently (to reduce the number of changes per refresh), or use full refreshes, or use something other than a MV?<br />
2. If you really want to cater for both small and large MV logs, why not perform dynamic sampling on the MV logs and let the CBO do its job?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blogroll Report 05/02/2010 – 12/03/2010 &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://www.adellera.it/blog/2010/03/11/fast-refresh-of-join-only-mvs-_mv_refresh_use_stats-and-locking-log-stats/comment-page-1/#comment-394</link>
		<dc:creator>Blogroll Report 05/02/2010 – 12/03/2010 &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Fri, 23 Apr 2010 01:08:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=426#comment-394</guid>
		<description>[...] 19-How to sort performance degradation of materialized view fast refreshes on versions after 9i?  Alberto D&#8217;ellera-fast refresh of join-only MVs: _mv_refresh_use_stats and locking log stats [...]</description>
		<content:encoded><![CDATA[<p>[...] 19-How to sort performance degradation of materialized view fast refreshes on versions after 9i?  Alberto D&#8217;ellera-fast refresh of join-only MVs: _mv_refresh_use_stats and locking log stats [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

