<?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: VPD / FGAC / RLS</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Mon, 20 May 2013 17:10:14 +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/2010/11/30/vpd-fgac-rls/#comment-38742</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 16 Dec 2010 18:38:24 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38742</guid>
		<description><![CDATA[Kevan,

Thanks for that information.

It&#039;s always interesting to see how features that individually can be very helpful don&#039;t always work when you combine them. It&#039;s one of the commonest types of problem that I find in my consultancy work.]]></description>
		<content:encoded><![CDATA[<p>Kevan,</p>
<p>Thanks for that information.</p>
<p>It&#8217;s always interesting to see how features that individually can be very helpful don&#8217;t always work when you combine them. It&#8217;s one of the commonest types of problem that I find in my consultancy work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevan Gelling</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38736</link>
		<dc:creator><![CDATA[Kevan Gelling]]></dc:creator>
		<pubDate>Thu, 16 Dec 2010 11:08:14 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38736</guid>
		<description><![CDATA[ORA_ROWSCN is not available on tables with a VPD policy and I&#039;ve found out why.

From bug 4947170:
&lt;blockquote&gt;&lt;i&gt;The problem stems from the fact that VPD builds a view to replace the table reference. The view text does not select the ORA_ROWSCN  pseudo column from the underlying table even if the outer query block  references it resulting in ORA-904.&lt;/i&gt;&lt;/blockquote&gt;

An enhancement request 6609789 has been raised and Oracle is working a solution.

Oracle provide the following workaround - since the ora_rowscn is available inside the policy function, add a dummy predicate as follows:
&lt;code&gt;&#124;&#124;&#039; AND f_ora_rowscn(&#039;&#124;&#124;object_name&#124;&#124;&#039;.ORA_ROWSCN) = 1&#039; &lt;/code&gt;

&lt;code&gt;CREATE OR REPLACE FUNCTION f_ora_rowscn( ROWSCN IN NUMBER )
RETURN NUMBER
AS
BEGIN
  DBMS_SESSION.SET_CONTEXT( &#039;STORE_ROWSCN&#039;, &#039;ROWSCN&#039;, ROWSCN ) ;
  RETURN 1 ;
END ;
/&lt;/code&gt;

&lt;code&gt;CREATE CONTEXT store_rowscn USING f_ora_rowscn ;&lt;/code&gt;

Also, to get the row_scn for each row, make it row dependant:

&lt;code&gt;CREATE OR REPLACE FUNCTION get_rowscn ( ROW IN ROWID ) RETURN VARCHAR2
AS
BEGIN
  RETURN SYS_CONTEXT( &#039;STORE_ROWSCN&#039;, &#039;ROWSCN&#039; ) ;
END;
/&lt;/code&gt;

Now to fetch the row scn in your application, use get_rowscn:

&lt;code&gt;SELECT t.*, get_rowscn( t.ROWID ) &quot;ORA_ROWSCN&quot; FROM test_table t ;&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>ORA_ROWSCN is not available on tables with a VPD policy and I&#8217;ve found out why.</p>
<p>From bug 4947170:</p>
<blockquote><p><i>The problem stems from the fact that VPD builds a view to replace the table reference. The view text does not select the ORA_ROWSCN  pseudo column from the underlying table even if the outer query block  references it resulting in ORA-904.</i></p></blockquote>
<p>An enhancement request 6609789 has been raised and Oracle is working a solution.</p>
<p>Oracle provide the following workaround &#8211; since the ora_rowscn is available inside the policy function, add a dummy predicate as follows:<br />
<code>||' AND f_ora_rowscn('||object_name||'.ORA_ROWSCN) = 1' </code></p>
<p><code>CREATE OR REPLACE FUNCTION f_ora_rowscn( ROWSCN IN NUMBER )<br />
RETURN NUMBER<br />
AS<br />
BEGIN<br />
  DBMS_SESSION.SET_CONTEXT( 'STORE_ROWSCN', 'ROWSCN', ROWSCN ) ;<br />
  RETURN 1 ;<br />
END ;<br />
/</code></p>
<p><code>CREATE CONTEXT store_rowscn USING f_ora_rowscn ;</code></p>
<p>Also, to get the row_scn for each row, make it row dependant:</p>
<p><code>CREATE OR REPLACE FUNCTION get_rowscn ( ROW IN ROWID ) RETURN VARCHAR2<br />
AS<br />
BEGIN<br />
  RETURN SYS_CONTEXT( 'STORE_ROWSCN', 'ROWSCN' ) ;<br />
END;<br />
/</code></p>
<p>Now to fetch the row scn in your application, use get_rowscn:</p>
<p><code>SELECT t.*, get_rowscn( t.ROWID ) "ORA_ROWSCN" FROM test_table t ;</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuri</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38632</link>
		<dc:creator><![CDATA[Yuri]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 08:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38632</guid>
		<description><![CDATA[I don`t know exactly, but I can suppose that it were long chains of child cursors. At least, I saw lots of child cursors for every query which used RLS protected objects. It seemed that for every user own child cursor was created. However by design, users were divided in groups (the same security predicates were generated), and cursors were to be shared among users in group.
The V$SQL_SHARED_CURSOR showed only two causes: AUTH_CHECK_MISMATCH and LANGUAGE_MISMATCH.
By the way it was APEX application with custom authentication schema. And as I remember, policies were created with static_policy=&gt;FALSE, but during experiments I recreated them with SHARED_CONTEXT_SENSITIVE and it relived the situation a little bit. Policy function were very lightweight, pure pl/sql without sql.]]></description>
		<content:encoded><![CDATA[<p>I don`t know exactly, but I can suppose that it were long chains of child cursors. At least, I saw lots of child cursors for every query which used RLS protected objects. It seemed that for every user own child cursor was created. However by design, users were divided in groups (the same security predicates were generated), and cursors were to be shared among users in group.<br />
The V$SQL_SHARED_CURSOR showed only two causes: AUTH_CHECK_MISMATCH and LANGUAGE_MISMATCH.<br />
By the way it was APEX application with custom authentication schema. And as I remember, policies were created with static_policy=&gt;FALSE, but during experiments I recreated them with SHARED_CONTEXT_SENSITIVE and it relived the situation a little bit. Policy function were very lightweight, pure pl/sql without sql.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38630</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 08:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38630</guid>
		<description><![CDATA[Yuri,

Thanks for supplying that information.

Do you know if the latching activity was caused by calls to the security functions, or by the fact that you can end up with a long chain of child cursors for the same SQL statement - which would all be covered by the same latch - when you use RLS ?]]></description>
		<content:encoded><![CDATA[<p>Yuri,</p>
<p>Thanks for supplying that information.</p>
<p>Do you know if the latching activity was caused by calls to the security functions, or by the fact that you can end up with a long chain of child cursors for the same SQL statement &#8211; which would all be covered by the same latch &#8211; when you use RLS ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuri</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38614</link>
		<dc:creator><![CDATA[Yuri]]></dc:creator>
		<pubDate>Thu, 09 Dec 2010 11:21:09 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38614</guid>
		<description><![CDATA[I had got bad experience with RLS on 10.2.0.1 and 10.2.0.3. It produced very heavy latch contention. But after I had made migration on 10.2.0.4 all problems disappeared. It seemed that new lightweight shared pool serialization mechanism was introduced in that release. I mean mutex. You can read about this on http://blog.tanelpoder.com/2008/08/03/library-cache-latches-gone-in-oracle-11g/]]></description>
		<content:encoded><![CDATA[<p>I had got bad experience with RLS on 10.2.0.1 and 10.2.0.3. It produced very heavy latch contention. But after I had made migration on 10.2.0.4 all problems disappeared. It seemed that new lightweight shared pool serialization mechanism was introduced in that release. I mean mutex. You can read about this on <a href="http://blog.tanelpoder.com/2008/08/03/library-cache-latches-gone-in-oracle-11g/" rel="nofollow">http://blog.tanelpoder.com/2008/08/03/library-cache-latches-gone-in-oracle-11g/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38079</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 04 Dec 2010 15:00:28 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38079</guid>
		<description><![CDATA[Rajaram,

Thanks for that - it&#039;s the type of comment that might save someone days of pointless effort.]]></description>
		<content:encoded><![CDATA[<p>Rajaram,</p>
<p>Thanks for that &#8211; it&#8217;s the type of comment that might save someone days of pointless effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38076</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 04 Dec 2010 14:52:12 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38076</guid>
		<description><![CDATA[Pat,

Thanks for the comments, and especially the bug numbers, it&#039;s the type of information that could be very helpful to anyone who finds this blog entry.
Nice to know that the Oracle developers have tried to take out the selectivity issues in 10g. (Of course there&#039;s no perfect solution with the extra predicates; sometimes you will want a different plan, sometimes you won&#039;t - it depends on the data, number of &quot;private databases&quot;, and different granularities of privilege)]]></description>
		<content:encoded><![CDATA[<p>Pat,</p>
<p>Thanks for the comments, and especially the bug numbers, it&#8217;s the type of information that could be very helpful to anyone who finds this blog entry.<br />
Nice to know that the Oracle developers have tried to take out the selectivity issues in 10g. (Of course there&#8217;s no perfect solution with the extra predicates; sometimes you will want a different plan, sometimes you won&#8217;t &#8211; it depends on the data, number of &#8220;private databases&#8221;, and different granularities of privilege)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat O</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-38050</link>
		<dc:creator><![CDATA[Pat O]]></dc:creator>
		<pubDate>Fri, 03 Dec 2010 13:47:47 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-38050</guid>
		<description><![CDATA[In our experiences/implementation, the actual overhead of OLS is measurable, but typically not an issue (there are of course exceptions to work through, but in general it would be more of a small but noticeable to barely visible depending on the operation in question).

The performance issue(s) for us are usually a side effect of OLS&#039; impact on the optimizer resulting in poor plans.  When we were on 9.2.0.x we discovered through some testing/10053 digging that the optimizer can&#039;t evaluate the predicates added by OLS (bug: 5674756,4200369).  The default filter factor for a predicate that can&#039;t be evaluated is 0.05, which was being added to multiple predicates on each protected table.  In our implementation the number of rows being filtered by OLS is generally small, or at least much smaller than 0.05 or (0.05*0.05) would filter. This would of course raise havoc on estimated cardinalities and resulting execution plans.

For 9.2.0.x to 10.2.x the bug was fixed by Oracle using a filter factor of 1.0 for OLS predicates instead of the default 0.05, resulting in plans that were typically identical to not having OLS at all.  This has been much better over all,  but we occasionally still have issues crop up where the plan for a labeled user is changed negatively compared to the same plan for a user with READ privilege that bypasses the policy.]]></description>
		<content:encoded><![CDATA[<p>In our experiences/implementation, the actual overhead of OLS is measurable, but typically not an issue (there are of course exceptions to work through, but in general it would be more of a small but noticeable to barely visible depending on the operation in question).</p>
<p>The performance issue(s) for us are usually a side effect of OLS&#8217; impact on the optimizer resulting in poor plans.  When we were on 9.2.0.x we discovered through some testing/10053 digging that the optimizer can&#8217;t evaluate the predicates added by OLS (bug: 5674756,4200369).  The default filter factor for a predicate that can&#8217;t be evaluated is 0.05, which was being added to multiple predicates on each protected table.  In our implementation the number of rows being filtered by OLS is generally small, or at least much smaller than 0.05 or (0.05*0.05) would filter. This would of course raise havoc on estimated cardinalities and resulting execution plans.</p>
<p>For 9.2.0.x to 10.2.x the bug was fixed by Oracle using a filter factor of 1.0 for OLS predicates instead of the default 0.05, resulting in plans that were typically identical to not having OLS at all.  This has been much better over all,  but we occasionally still have issues crop up where the plan for a labeled user is changed negatively compared to the same plan for a user with READ privilege that bypasses the policy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Polarski</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-37994</link>
		<dc:creator><![CDATA[Bernard Polarski]]></dc:creator>
		<pubDate>Wed, 01 Dec 2010 11:52:35 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-37994</guid>
		<description><![CDATA[Already implemented FGAC and it affected negatively some of the queries very negatively. Fix was easy, taking stored outlines when FGAC is off and  activating them before FGAC on. After that did not notice any perf degradation. This was on OLTP, Linux blade 2 core, with avg 70tx/secs.]]></description>
		<content:encoded><![CDATA[<p>Already implemented FGAC and it affected negatively some of the queries very negatively. Fix was easy, taking stored outlines when FGAC is off and  activating them before FGAC on. After that did not notice any perf degradation. This was on OLTP, Linux blade 2 core, with avg 70tx/secs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajaram Subramanian</title>
		<link>http://jonathanlewis.wordpress.com/2010/11/30/vpd-fgac-rls/#comment-37992</link>
		<dc:creator><![CDATA[Rajaram Subramanian]]></dc:creator>
		<pubDate>Wed, 01 Dec 2010 10:56:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5002#comment-37992</guid>
		<description><![CDATA[Most annoying issue what I have faced with OLS/VPD implementation is the following limitation in XMLDB.  When OLS/VPD is implemented in a XMLDB oracle cannot use the O-R feature because of the fundamental limitation. 

Metalink note : 761921.1

Regards]]></description>
		<content:encoded><![CDATA[<p>Most annoying issue what I have faced with OLS/VPD implementation is the following limitation in XMLDB.  When OLS/VPD is implemented in a XMLDB oracle cannot use the O-R feature because of the fundamental limitation. </p>
<p>Metalink note : 761921.1</p>
<p>Regards</p>
]]></content:encoded>
	</item>
</channel>
</rss>
