http://www.bobbydurrettdba.com/2012/07/17/two-ways-to-see-predicates-added-by-vpd-or-fgac/

Two ways to see predicates added by VPD or FGAC

Posted on July 17, 2012 by Bobby

We use a feature called “Virtual Private Database” or VPD on our 11g database.  This looks a lot like what used to be called “Fine Grained Access Control” or FGAC on our 10g database.  The idea behind both of these features is that a particular user in a particular situation would see a tailored view of the data rather than have all users see all of the data all the time.  VPD or FGAC accomplishes this feat by secretly adding predicates to a user’s query’s where clause predicates so they only see the rows allowed by that predicate.

The problem is that when you need to tune a poorly performing query that accesses tables protected by VPD you can’t see the real query through any of the normal methods.  Even a 10046 trace just gives you the unmodified query as the user ran it not the one with the new VPD additions.  I found two ways to see what the real where clause conditions are after the query is modified by VPD – dbms_xplan.display_cursor and 10053 trace.

Here is how to use dbms_xplan.display_cursor to show the VPD predicates:

SQL> select count(*) from test.table_list;

  COUNT(*)
----------
      1858 SQL> select * from table(
dbms_xplan.display_cursor(null,null,'ALLSTATS')); PLAN_TABLE_OUTPUT
-------------------------------------------------------
SQL_ID  2fuam6x1dyt5v, child number 0
-------------------------------------
select count(*) from test.table_list Plan hash value: 1374414456 --------------------------------------------------
| Id  | Operation          | Name       | E-Rows |
--------------------------------------------------
|   0 | SELECT STATEMENT   |            |        |
|   1 |  SORT AGGREGATE    |            |      1 |
|*  2 |   TABLE ACCESS FULL| TABLE_LIST |   2028 |
-------------------------------------------------- Predicate Information (identified by operation id):
---------------------------------------------------    2 - filter("OWNER"<>'SYS')

Note that the predicate owner<>’SYS’ isn’t in the query but was added by the VPD.  The idea here is that the table TEST.TABLE_LIST contains a list of table names but the user doing the query doesn’t have permission to see the names of the tables owned by SYS.

Here is how to use a 10053 trace to see the VPD predicates:

ALTER SESSION SET EVENTS
'10053 trace name context forever, level 1'; select /* comment to force parse */ count(*) from test.table_list; ALTER SESSION SET EVENTS '10053 trace name context OFF'; trace output: Final query after transformations:******* UNPARSED QUERY IS *******
SELECT COUNT(*) "COUNT(*)" FROM "TEST"."TABLE_LIST" "TABLE_LIST"
WHERE "TABLE_LIST"."OWNER"<>'SYS'

I had to add the comment to make sure the query got reparsed.  The 10053 trace only produces a trace when a query is parsed.  Note that the trace file has the description: “Final query after transformations”.  I’m not sure what all transformations are possible but it stands to reason that using a 10053 trace will give you a clearer picture of the real query being parsed.  It shows you the text the parser itself starts with before it starts to break it down into an execution plan that can be run.

alter session set tracefile_identifier='test_lv123';
ALTER SESSION SET EVENTS
'10053 trace name context forever, level 1';

SELECT /* comment to force parse */ * FROM oe_order_headers;

ALTER SESSION SET EVENTS '10053 trace name context OFF';

SELECT U_DUMP.VALUE || '/' || DB_NAME.VALUE || '_ora_' || V$PROCESS.SPID ||
NVL2(V$PROCESS.TRACEID, '_' || V$PROCESS.TRACEID, NULL) || '.trc' "Trace File"
FROM V$PARAMETER U_DUMP
CROSS JOIN V$PARAMETER DB_NAME
CROSS JOIN V$PROCESS
JOIN V$SESSION
ON V$PROCESS.ADDR = V$SESSION.PADDR
WHERE U_DUMP.NAME = 'user_dump_dest'
AND DB_NAME.NAME = 'db_name'
AND V$SESSION.AUDSID = SYS_CONTEXT('userenv', 'sessionid');

Two ways to see predicates added by VPD or FGAC的更多相关文章

  1. C++ Knowledge series 3

    Programming language evolves always along with Compiler's evolvement The Semantics of Data The size ...

  2. 【leetcode】Decode Ways(medium)

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  3. ASP.NET MVC3 Dynamically added form fields model binding

    Adding  new Item to a list of items, inline is a very nice feature you can provide to your user. Thi ...

  4. QMP ( qemu monitor protocol ) and Different ways of accessing it

    The QEMU Monitor Protocol (QMP) is a JSON-based protocol which allows applications to communicate wi ...

  5. dapper extensions (predicates)

    https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates The predicate system in Dapper Extensio ...

  6. [AngularJS] 5 simple ways to speed up your AngularJS application

    Nowdays, Single page apps are becoming increasingly popular among the fornt-end developers. It is th ...

  7. ASP.NET MVC:4 Ways To Prevent Duplicate Form Submission(转载)

    原文地址:http://technoesis.net/prevent-double-form-submission/. Double form submission in a multi-user w ...

  8. Four Ways to Create a Thread

    Blaise Pascal Magazine Rerun #5: Four Ways to Create a Thread   This article was originally written ...

  9. Recommend ways to overwrite hashCode() in java

    Perface In the former chapter, I talk about topics about hashCode, And I will continue to finish the ...

随机推荐

  1. 【Java】JVM(三)、Java垃圾收集器

    一.Minor GC.Major GC 和 Full GC Minor GC:清理新生代空间,当Eden空间不能分配时候引发Minor GC Major GC:清理老年代空间 Full GC:清理Ja ...

  2. fasta/fastq格式解读

    1)知识简介--------------------------------------------------------1.1)测序质量值 首先在了解fastq,fasta之前,了解一下什么是质量 ...

  3. Linux下tar.gz 安装

    将安装文件拷贝至你的目录中 如果是以root身份登录上的,就将软件拷贝至/root中. cp xxx.tar.gz /root 解压缩包 tar xvzf xxx.tar.gz 切换到安装目录下 cd ...

  4. go语言中通过http访问需要认证的api

    func main() { //生成client 参数为默认 client := &http.Client{} //生成要访问的url url := "https://api.XXX ...

  5. codeblocks 更换颜色主题

    关闭codeblocks,下载主题文件(colour_themes.conf).在关闭codeblocks的情况下,linux下的~/.config/codeblocks/下有个conf文件,将其备份 ...

  6. .NET中的Request

    获得浏览器中的URL 例:http://121.41.30.93:8010/ch/spell.aspx?id=58 Request.Url.PathAndQuery:/ch/spell.aspx?id ...

  7. ASP.NET MVC HtmlHelper 默认值

    例如: @Html.HiddenFor(m=>m.IsMating,new { Value="True"}) 注意:value属性的首字母要用大写.

  8. 不要用for in语句对数组进行遍历

    for...in主要用于对数组和对象的属性进行遍历.for ... in 循环中的代码每执行一次,就会对数组的元素或者对象的属性进行一次操作. 语法:for (variable in object) ...

  9. geoserver 开发1

    打开项目,会看见下面这些包(其实还有很多插件之类的包,我都删除了) 5)可以从Eclipse启动GeoServer了. 如果你已经安装了GeoServer,现在也可以打开它的登陆页面进行操作. 三 结 ...

  10. BZOJ1221 [HNOI2001]软件开发 - 费用流

    题解 非常显然的费用流. 但是建图还是需要思考的QuQ 将每天分成两个节点 $x_{i,1}, x_{i,2} $, $ x_{i,1}$用于提供服务, $x_{i ,2}$ 用来从源点获得$nd[i ...