Two ways to see predicates added by VPD or FGAC
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
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的更多相关文章
- C++ Knowledge series 3
Programming language evolves always along with Compiler's evolvement The Semantics of Data The size ...
- 【leetcode】Decode Ways(medium)
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- 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 ...
- 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 ...
- dapper extensions (predicates)
https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates The predicate system in Dapper Extensio ...
- [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 ...
- 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 ...
- Four Ways to Create a Thread
Blaise Pascal Magazine Rerun #5: Four Ways to Create a Thread This article was originally written ...
- 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 ...
随机推荐
- console.log等不能打印全部数据/信息
有时候console.log在chrome调试控制台打印不全,如下: 这个时候,我们可以点击进去:用watch 工具,添加变量,右击copy value 选项:
- 关于oracle数据库
Oracle数据库是做什么的? oracle数据库和其他数据库一样,都是保存数据的,同时可以去查询,修改,删除等oracle和其他数据不一样的地方在于,它又复杂的机制可以保证在数据库服务器突然坏了的情 ...
- 第八章 高级搜索树 (a3)伸展树:算法实现
- ubuntu安装谷歌拼音输入法
在这篇教程中,我将告诉你如何在ubuntu系统上安装谷歌拼音输入法.谷歌拼音输入法有基于ibus框架的,也有基于fcitx框架的.我只演示fcitx框架下谷歌拼音输入法的安装,因为ibus框架的谷歌拼 ...
- 数据库事务(Database Transaction)
事务(Transaction)是访问并可能更新数据库中各种数据项的一个程序执行单元(unit).事务由事务开始(begin transaction)和事务结束(commit transaction或 ...
- 二级联动的作业&左右移动作业
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SyntaxError: Non-ASCII character '\xe5' in file D:/pcode/xx.py on line 21, but no encoding declared
from selenium import webdriver from datetime import * import time starttime = datetime.now() print ( ...
- session总结
1.session是服务器端内存中的一块存储空间. 2.不同的浏览器窗口对应着不同的Session对象,两者的关系由Session ID来进行维护. 3.session的生命周期是以最后一次请求到达服 ...
- Linq和EF 做 单一条件查询 和 复合条件 查询 以及 多表 联合查询 示例
单一条件查询: var table2Object = (from t1 in db.table1 join t2 in db.table2 on t1.id equals t2.id select t ...
- sublime Text与python3的中文编码错误解决办法
在 linux服务器上运行代码报错: Python3中遇到UnicodeEncodeError: ‘ascii’ codec can’t encode characters in ordinal no ...