<?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: 11gR2: new algorithm for fast refresh of on-commit materialized views</title>
	<atom:link href="http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/</link>
	<description>A blog about Oracle - Un blog riguardo Oracle</description>
	<lastBuildDate>Wed, 11 Aug 2010 14:30:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alberto Dell'Era</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-309</link>
		<dc:creator>Alberto Dell'Era</dc:creator>
		<pubDate>Thu, 07 Jan 2010 09:25:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-309</guid>
		<description>@Taral

thanks for coming back and letting me know about your solution.</description>
		<content:encoded><![CDATA[<p>@Taral</p>
<p>thanks for coming back and letting me know about your solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taral Desai</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-308</link>
		<dc:creator>Taral Desai</dc:creator>
		<pubDate>Thu, 07 Jan 2010 06:03:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-308</guid>
		<description>Thanks Sir for update and also explaining both things. As usual i learned many things from you today thank you for that. Now, coming to the issue this is actually a bug and i tested using the method provide in document 578720.1 and now it&#039;s using path

[sql]
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          0          0           0
Execute      1      0.01       0.00          0          8          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.02       0.01          0          8          0           0


Rows     Row Source Operation
-------  ---------------------------------------------------
      0  NESTED LOOPS  (cr=8 pr=0 pw=0 time=432 us)
      1   NESTED LOOPS  (cr=7 pr=0 pw=0 time=402 us)
      1    VIEW  (cr=4 pr=0 pw=0 time=269 us)
      1     NESTED LOOPS  (cr=4 pr=0 pw=0 time=265 us)
      1      SORT UNIQUE (cr=3 pr=0 pw=0 time=235 us)
      2       TABLE ACCESS FULL MLOG$_xxxx (cr=3 pr=0 pw=0 time=143 us)
      1      TABLE ACCESS BY USER ROWID S_XXXX (cr=1 pr=0 pw=0 time=23 us)
      1    TABLE ACCESS BY INDEX ROWID S_XXXX (cr=3 pr=0 pw=0 time=127 us)
      1     INDEX UNIQUE SCAN SXXXXX_PK (cr=2 pr=0 pw=0 time=55 us)(object id 52121)
      0   INDEX UNIQUE SCAN PK_S_XXXXX (cr=1 pr=0 pw=0 time=25 us)(object id 87853)
[/sql]</description>
		<content:encoded><![CDATA[<p>Thanks Sir for update and also explaining both things. As usual i learned many things from you today thank you for that. Now, coming to the issue this is actually a bug and i tested using the method provide in document 578720.1 and now it&#8217;s using path</p>
<pre class="brush: sql;">
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          0          0           0
Execute      1      0.01       0.00          0          8          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.02       0.01          0          8          0           0

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  NESTED LOOPS  (cr=8 pr=0 pw=0 time=432 us)
      1   NESTED LOOPS  (cr=7 pr=0 pw=0 time=402 us)
      1    VIEW  (cr=4 pr=0 pw=0 time=269 us)
      1     NESTED LOOPS  (cr=4 pr=0 pw=0 time=265 us)
      1      SORT UNIQUE (cr=3 pr=0 pw=0 time=235 us)
      2       TABLE ACCESS FULL MLOG$_xxxx (cr=3 pr=0 pw=0 time=143 us)
      1      TABLE ACCESS BY USER ROWID S_XXXX (cr=1 pr=0 pw=0 time=23 us)
      1    TABLE ACCESS BY INDEX ROWID S_XXXX (cr=3 pr=0 pw=0 time=127 us)
      1     INDEX UNIQUE SCAN SXXXXX_PK (cr=2 pr=0 pw=0 time=55 us)(object id 52121)
      0   INDEX UNIQUE SCAN PK_S_XXXXX (cr=1 pr=0 pw=0 time=25 us)(object id 87853)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Dell'Era</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-307</link>
		<dc:creator>Alberto Dell'Era</dc:creator>
		<pubDate>Wed, 06 Jan 2010 21:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-307</guid>
		<description>@Taral

I concurr on the performance problem being the Hash Join; there your statement spends the vast majority of time (22980548 microseconds), that is almost completely CPU or unaccounted-for time (since the two child FTS accounts for only 135+8272772 microseconds). 

About the question about the semi-join, you have a SQL semi-join since a fragment of the statement used for the INS phase of the fast refresh is

select .. from test_t1 where rowid in ( select ... from mlog$_test_t1 )

There are (conceptually) two ways to calculate this fragment using an hash table:

a) load test_t1 as an hash table &quot;in memory&quot;, then read mlog$_test_t1, and mark the rows in the hash table that match; then, return the marked rows

b) load mlog$_test_t1 as an hash table &quot;in memory&quot;, then read test_t1; whenever a match occurs, return the row, and mark the hash table row as &quot;already returned&quot;, and never return it again even if another match occurs [or, simply remove the row from the hash table].

I&#039;m almost sure that (a) is how an &quot;HASH JOIN SEMI&quot; works, and (b) is how an &quot;HASH JOIN RIGHT SEMI&quot; works, even if I am only 95% sure right now. If that&#039;s true, in the common scenario where the log contains only a few rows and  the table a lot of rows (as it seems to be your case), (b) would seem to be the more efficient way (small hash table).

It would be interesting to compare two tkprofs of the fragment, one using (a) and another (b) (you can use the swap_join_inputs and no_swap_join_inputs to force one or another), and see whether it makes any difference.

Of course one would argue that the most efficient way to compute that fragment would be to get the table rows &quot;pointed to&quot; by the log rowids, thus avoiding a very expensive FTS, not by an expensive hash join. The hash join was chosen in my tests because the tables were tiny; in general, I do not expect that path to be chosen very often.

Might you check that the CBO was working with up-to-date information, by checking that
a) table S_R had up-to-date statistics collected
and
b) the log MLOG$_S_R had either up-to-date statistics or no statistics (both scenarios are possible).</description>
		<content:encoded><![CDATA[<p>@Taral</p>
<p>I concurr on the performance problem being the Hash Join; there your statement spends the vast majority of time (22980548 microseconds), that is almost completely CPU or unaccounted-for time (since the two child FTS accounts for only 135+8272772 microseconds). </p>
<p>About the question about the semi-join, you have a SQL semi-join since a fragment of the statement used for the INS phase of the fast refresh is</p>
<p>select .. from test_t1 where rowid in ( select &#8230; from mlog$_test_t1 )</p>
<p>There are (conceptually) two ways to calculate this fragment using an hash table:</p>
<p>a) load test_t1 as an hash table &#8220;in memory&#8221;, then read mlog$_test_t1, and mark the rows in the hash table that match; then, return the marked rows</p>
<p>b) load mlog$_test_t1 as an hash table &#8220;in memory&#8221;, then read test_t1; whenever a match occurs, return the row, and mark the hash table row as &#8220;already returned&#8221;, and never return it again even if another match occurs [or, simply remove the row from the hash table].</p>
<p>I&#8217;m almost sure that (a) is how an &#8220;HASH JOIN SEMI&#8221; works, and (b) is how an &#8220;HASH JOIN RIGHT SEMI&#8221; works, even if I am only 95% sure right now. If that&#8217;s true, in the common scenario where the log contains only a few rows and  the table a lot of rows (as it seems to be your case), (b) would seem to be the more efficient way (small hash table).</p>
<p>It would be interesting to compare two tkprofs of the fragment, one using (a) and another (b) (you can use the swap_join_inputs and no_swap_join_inputs to force one or another), and see whether it makes any difference.</p>
<p>Of course one would argue that the most efficient way to compute that fragment would be to get the table rows &#8220;pointed to&#8221; by the log rowids, thus avoiding a very expensive FTS, not by an expensive hash join. The hash join was chosen in my tests because the tables were tiny; in general, I do not expect that path to be chosen very often.</p>
<p>Might you check that the CBO was working with up-to-date information, by checking that<br />
a) table S_R had up-to-date statistics collected<br />
and<br />
b) the log MLOG$_S_R had either up-to-date statistics or no statistics (both scenarios are possible).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taral Desai</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-306</link>
		<dc:creator>Taral Desai</dc:creator>
		<pubDate>Wed, 06 Jan 2010 05:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-306</guid>
		<description>Hello Alberto,

I have some problem with mv where i am using 10.2.0.4. I saw your trace file and in that it uses 

[sql]
Rows     Row Source Operation
-------  ---------------------------------------------------
      2  TABLE ACCESS BY INDEX ROWID TEST_T1 (cr=21 pr=0 pw=0 time=4362 us)
      5   NESTED LOOPS  (cr=20 pr=0 pw=0 time=4307 us)
      2    NESTED LOOPS  (cr=18 pr=0 pw=0 time=4217 us)
      3     VIEW  (cr=14 pr=0 pw=0 time=3887 us)
      3      HASH JOIN SEMI (cr=14 pr=0 pw=0 time=3865 us)
    100       TABLE ACCESS FULL TEST_T3 (cr=7 pr=0 pw=0 time=308 us)
      6       TABLE ACCESS FULL MLOG$_TEST_T3 (cr=7 pr=0 pw=0 time=105 us)
      2     TABLE ACCESS BY INDEX ROWID TEST_T2 (cr=4 pr=0 pw=0 time=120 us)
      2      INDEX RANGE SCAN TEST_T2_J2_3_IDX (cr=2 pr=0 pw=0 time=67 us)(object id 60236)
      2    INDEX RANGE SCAN TEST_T1_J1_2_IDX (cr=2 pr=0 pw=0 time=43 us)(object id 60230)


[/sql]

Hash join semi. Where i have problem uses hash  join right semi. What is different between them ? This i think is causing performace issue in my case

[sql]
Rows     Row Source Operation
-------  ---------------------------------------------------
      1  NESTED LOOPS  (cr=55325 pr=53317 pw=0 time=22980681 us)
      1   NESTED LOOPS  (cr=55324 pr=53317 pw=0 time=22980657 us)
      1    VIEW  (cr=55321 pr=53317 pw=0 time=22980562 us)
      1     HASH JOIN RIGHT SEMI (cr=55321 pr=53317 pw=0 time=22980548 us)
      2      TABLE ACCESS FULL MLOG$_S_R (cr=3 pr=0 pw=0 time=135 us)
8264128      TABLE ACCESS FULL S_R (cr=55318 pr=53317 pw=0 time=8272772 us)
      1    TABLE ACCESS BY INDEX ROWID SERVICE_REQUESTS (cr=3 pr=0 pw=0 time=86 us)
      1     INDEX UNIQUE SCAN xxxx_PK (cr=2 pr=0 pw=0 time=40 us)(object id 52121)
      1   INDEX UNIQUE SCAN PK_Sxxxxx (cr=1 pr=0 pw=0 time=12 us)(object id 87853)

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        5      0.01       0.01          0          0          0           0
Execute      5     50.73      61.04     266390     276650         80           5
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10     50.74      61.06     266390     276650         80           5

[/sql]

Table and index name are changed due to policy. So, i think most time is spent on hash join right semi. Can you please guide me how to improve this</description>
		<content:encoded><![CDATA[<p>Hello Alberto,</p>
<p>I have some problem with mv where i am using 10.2.0.4. I saw your trace file and in that it uses </p>
<pre class="brush: sql;">
Rows     Row Source Operation
-------  ---------------------------------------------------
      2  TABLE ACCESS BY INDEX ROWID TEST_T1 (cr=21 pr=0 pw=0 time=4362 us)
      5   NESTED LOOPS  (cr=20 pr=0 pw=0 time=4307 us)
      2    NESTED LOOPS  (cr=18 pr=0 pw=0 time=4217 us)
      3     VIEW  (cr=14 pr=0 pw=0 time=3887 us)
      3      HASH JOIN SEMI (cr=14 pr=0 pw=0 time=3865 us)
    100       TABLE ACCESS FULL TEST_T3 (cr=7 pr=0 pw=0 time=308 us)
      6       TABLE ACCESS FULL MLOG$_TEST_T3 (cr=7 pr=0 pw=0 time=105 us)
      2     TABLE ACCESS BY INDEX ROWID TEST_T2 (cr=4 pr=0 pw=0 time=120 us)
      2      INDEX RANGE SCAN TEST_T2_J2_3_IDX (cr=2 pr=0 pw=0 time=67 us)(object id 60236)
      2    INDEX RANGE SCAN TEST_T1_J1_2_IDX (cr=2 pr=0 pw=0 time=43 us)(object id 60230)
</pre>
<p>Hash join semi. Where i have problem uses hash  join right semi. What is different between them ? This i think is causing performace issue in my case</p>
<pre class="brush: sql;">
Rows     Row Source Operation
-------  ---------------------------------------------------
      1  NESTED LOOPS  (cr=55325 pr=53317 pw=0 time=22980681 us)
      1   NESTED LOOPS  (cr=55324 pr=53317 pw=0 time=22980657 us)
      1    VIEW  (cr=55321 pr=53317 pw=0 time=22980562 us)
      1     HASH JOIN RIGHT SEMI (cr=55321 pr=53317 pw=0 time=22980548 us)
      2      TABLE ACCESS FULL MLOG$_S_R (cr=3 pr=0 pw=0 time=135 us)
8264128      TABLE ACCESS FULL S_R (cr=55318 pr=53317 pw=0 time=8272772 us)
      1    TABLE ACCESS BY INDEX ROWID SERVICE_REQUESTS (cr=3 pr=0 pw=0 time=86 us)
      1     INDEX UNIQUE SCAN xxxx_PK (cr=2 pr=0 pw=0 time=40 us)(object id 52121)
      1   INDEX UNIQUE SCAN PK_Sxxxxx (cr=1 pr=0 pw=0 time=12 us)(object id 87853)

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        5      0.01       0.01          0          0          0           0
Execute      5     50.73      61.04     266390     276650         80           5
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10     50.74      61.06     266390     276650         80           5
</pre>
<p>Table and index name are changed due to policy. So, i think most time is spent on hash join right semi. Can you please guide me how to improve this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Dell'Era</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-298</link>
		<dc:creator>Alberto Dell'Era</dc:creator>
		<pubDate>Thu, 17 Dec 2009 18:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-298</guid>
		<description>@Joaquin

for join-only MVs, that is, the kind of MV investigated in this post, sure. 

Anyway, I always check the actual algorithm using the actual SQL statement and the exact database version I am using for important MVs; better safe than sorry... you can easily adapt my test case for that purpose. 

I don&#039;t think that setting pctfree to zero is going to improve the performance too much - at most it might reduce the resource consumption of full table scans by 10%, which is not that much.</description>
		<content:encoded><![CDATA[<p>@Joaquin</p>
<p>for join-only MVs, that is, the kind of MV investigated in this post, sure. </p>
<p>Anyway, I always check the actual algorithm using the actual SQL statement and the exact database version I am using for important MVs; better safe than sorry&#8230; you can easily adapt my test case for that purpose. </p>
<p>I don&#8217;t think that setting pctfree to zero is going to improve the performance too much &#8211; at most it might reduce the resource consumption of full table scans by 10%, which is not that much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joaquin</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-297</link>
		<dc:creator>Joaquin</dc:creator>
		<pubDate>Thu, 17 Dec 2009 17:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-297</guid>
		<description>Hi Alberto,

It seems that materialized views are refreshed using only deletes and inserts, am I right? If that&#039;s true, then there&#039;s no reason for the pctfree of the materialized view to be not equal to zero, right?

Thank you!

Joaquin Gonzalez</description>
		<content:encoded><![CDATA[<p>Hi Alberto,</p>
<p>It seems that materialized views are refreshed using only deletes and inserts, am I right? If that&#8217;s true, then there&#8217;s no reason for the pctfree of the materialized view to be not equal to zero, right?</p>
<p>Thank you!</p>
<p>Joaquin Gonzalez</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blogroll Report 20/11/2009-27/11/2009 &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-284</link>
		<dc:creator>Blogroll Report 20/11/2009-27/11/2009 &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Sat, 12 Dec 2009 19:04:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-284</guid>
		<description>[...] 4-How does fast refresh of on-commit materialized views works on 11GR2? Alberto Dell&#8217;era-11gR2: new algorithm for fast refresh of on-commit materialized views  [...]</description>
		<content:encoded><![CDATA[<p>[...] 4-How does fast refresh of on-commit materialized views works on 11GR2? Alberto Dell&#8217;era-11gR2: new algorithm for fast refresh of on-commit materialized views  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://www.adellera.it/blog/2009/11/22/11gr2-new-algorithm-for-fast-refresh-of-on-commit-materialized-views/comment-page-1/#comment-278</link>
		<dc:creator>Igor</dc:creator>
		<pubDate>Fri, 04 Dec 2009 14:44:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.adellera.it/blog/?p=385#comment-278</guid>
		<description>Hi Alberto, 

I agree with your point of view. (just don&#039;t tell to tkyte about it. Just kidding... :-)

Thank you for these insights.</description>
		<content:encoded><![CDATA[<p>Hi Alberto, </p>
<p>I agree with your point of view. (just don&#8217;t tell to tkyte about it. Just kidding&#8230; :-)</p>
<p>Thank you for these insights.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
