Detailed description of Oracle internal function call Tracker

Source: Internet
Author: User
Based on TopShow, a previously developed tool used to monitor the CPU usage of threads, I developed a tracker for tracking Oracle internal function calls-OraTracer. you can use this tool to track and monitor the calls of multiple internal functions in Oracle. You can also try to detect the input parameters of the function, or print the call heap when the tracing point is triggered.

Based on TopShow, a previously developed tool used to monitor the CPU usage of threads, I developed a tracker for tracking Oracle internal function calls-OraTracer. you can use this tool to track and monitor the calls of multiple internal functions in Oracle. You can also try to detect the input parameters of the function, or print the call heap when the tracing point is triggered.

Based on TopShow, a previously developed tool used to monitor the CPU usage of threads, I developed a tracker for tracking Oracle internal function calls-OraTracer. you can use this tool to track and monitor the calls of multiple internal functions in Oracle. You can also try to detect the input parameter values of the function, or print the call stack when the tracing point is triggered. Tracking can be set at the level of the entire Oracle process, or in a thread to track a specific session.

Example 1:

Capture the SQL statements executed in the entire oracle instance.

First, set the tracking file tracepoints.txt in the directory that is the same as the executable file. The content is as follows:

_ Opiprs 6*1

_ Rpisplu 6*2

_ Kprbprs 6

The number of parameters separated by spaces in the function name is the number of parameters to be tested. If "* N" is added, the system tries to treat the double-byte number as a pointer and recursively obtain the executed value, the following number indicates the recursive depth. For example, for the first tracking point, the function name is "_ opiprs" and six parameters are tested. The depth of the recursive detection pointer data is 1.

Note: "#" is the annotator.

Then select "ORACLE. EXE" from the process list. Do not select any thread:

Finally, click "Trace. Once a statement is called by the above function, you can see these statements in the monitoring window:

SQL code

...

[3:53:23. 426] User call: _ rpisplu (TID: 5276)

[Args (6)]:

6

0

0

"Select privilege #, level from sysauth $ connect by grantee # = prior privilege # and privilege #> 0 start with grantee # =: 1 and privilege #> 0"

0 × 84 (=> NULL)

0

[3:53:23. 442] User call: _ rpisplu (TID: 5276)

[Args (6)]:

6

0

0

"Alter session set NLS_LANGUAGE = 'American 'nls_territory = 'America 'nls_currency = '$ 'nls_iso_currency = 'America 'nls_numeric_characters = '., 'nls_date_format = 'dd-MON-RR 'NLS_DATE_LANGUAGE = 'American 'nls_sort = 'binary'

0xd4 (=> NULL)

0

[3:53:23. 473] User call: _ opiprs (TID: 5276)

[Args (6)]:

0 × 70cce00 (=> 0 × 4000000)

"Alter session set NLS_LANGUAGE = 'American 'nls_territory = 'America 'nls_currency = '$ 'nls_iso_currency = 'America 'nls_numeric_characters = '., 'nls_date_format = 'dd-MON-RR 'NLS_DATE_LANGUAGE = 'American 'nls_sort = 'binary'

0xd5 (=> NULL)

0 × 4bfe214 (=> 0 × 18)

0

6

[3:53:23. 504] User call: _ rpisplu (TID: 5276)

[Args (6)]:

3

0 × 20 (=> NULL)

0 × 20 (=> NULL)

"Select sysdate + 1/(24*60) from dual"

0 × 28 (=> NULL)

1

[3:53:23. 520] User call: _ rpisplu (TID: 5276)

[Args (6)]:

5

0 × 20 (=> NULL)

0 × 20 (=> NULL)

"DECLARE job BINARY_INTEGER: =: job; next_date DATE: =: mydate; broken BOOLEAN: = FALSE; BEGIN values ();: mydate: = next_date; IF broken THEN: B: = 1; ELSE: B: = 0; END IF; END;"

0xd5 (=> NULL)

0

...

Click "Stop" to Stop tracing.

Example 2:

Understand how SQL is driven by execution plans.

We know that the query plan actually drives Oracle to obtain data through specific functions and sequences. We can track these functions to understand the execution plan.

Download the file first, decompress it, and rename it as tracepoints.txtfolder. Put it in the directory of oratracer.exe:

Http://www.HelloDBA.com/download/TracePoints_ALL_Query_Calls.zip

Then get the spid of the session you want to trace:

SQL code

HELLODBA. COM> select distinct spid from v $ mystat m, v $ session s, v $ process p where s. sid = m. sid and s. paddr = p. addr;

SPID

----

11076

Select ORACLE. EXE => threads whose TID is 11076 from the process list => click "Trace"

Execute a statement in the tracked session:

SQL code

HELLODBA. COM> select * from demo. t_test1 where owner = 'Demo' and object_name like't _ TEST % ';

OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED

LAST_DDL_TIME TIMESTAMP STATUS T G S

--------------------------------------------------

-----------------------

DEMO T_TEST1 AAA 97819 97819 TABLE

13:48:08 13:48:08: 13: 48: 08 VALID N

Note: To avoid rollback calls being tracked, you 'd better run this statement once before tracing.

We can see the data fetch call from the tracing window:

SQL code

[6:28:29. 649] User call: _ qertbFetchByRowID (TID: 11076)

[6:28:29. 711] User call: _ qerixtFetch (TID: 11076)

[6:28:29. 727] User call: _ qertbFetchByRowID (TID: 11076)

[6:28:29. 727] User call: _ qerixtFetch (TID: 11076)

With such tracing records, you can try to map them to nodes in the execution plan:

SQL code

HELLODBA. COM> select * from demo. t_test1 where owner = 'Demo' and object_name like't _ TEST % ';

Execution Plan

--------------------

Plan hash value: 698582444

-------------------------------

| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |

-------------------------------

| 0 | select statement | 5 | 495 | 4 (0) | 00:00:04 |

| 1 | table access by index rowid | T_TEST1 | 5 | 495 | 4 (0) | 00:00:04 |=> _ qertbFetchByRowID

| * 2 | index range scan | T_TEST_IDX7 | 5 | 1 (0) | 00:00:02 | ==>_qerixtfetch

Example 3:

Prints the thread call stack when a specific function is called.

Here we track "_ kkeAdjSingTabCard ". Set Tracing points:

SQL code

_ KkeAdjSingTabCard *-1 6

The "* N" after the function name specifies the number of output calls.-1 is unlimited.

Then get the spid of the session you want to trace:

SQL code

HELLODBA. COM> select distinct spid from v $ mystat m, v $ session s, v $ process p where s. sid = m. sid and s. paddr = p. addr;

SPID

----

11076

Select ORACLE. EXE => threads whose TID is 11076 from the process list => click "Trace"

Explain a statement in the tracked session:

SQL code

HELLODBA. COM> explain plan for select/* + full (t) */count (*) from demo. t_test2 t;

Explained.

We can obtain the entire call stack when the function is called from the monitoring window:

SQL code

[6:51:55. 591] User call: _ kkeAdjSingTabCard (TID: 11076)

Call Stacks (-1 ):

0 × 1460029 (ORACLE. EXE! _ Kkoitbp + 757)

0 × 144c44d (ORACLE. EXE! _ Kkoijbad + 8869)

0 × 1445d8b (ORACLE. EXE! _ KkoCopyPreds + 851)

0 × 143ee0a (ORACLE. EXE! _ Kkosta + 1694)

0 × 1d17f6c (ORACLE. EXE! _ PGOSF443 _ apaRequestBindCapture + 156)

0 × 1d18398 (ORACLE. EXE! _ Apagcp + 388)

0 × 1d1683c (ORACLE. EXE! _ Apafbr + 464)

0xea6682 (ORACLE. EXE! -OpitcaNcp + 1450)

0 × 5b4eb0 (ORACLE. EXE! _ KksMinimalTypeCheck + 20)

0 × 84d939 (ORACLE. EXE! _ Rpidrus + 429)

0 × 5b8ce8 (ORACLE. EXE! _ Kssetnlshandle + 5888)

0 × 87732e (ORACLE. EXE! _ KxsReleaseRuntimeLock + 1366)

0 × 831815 (ORACLE. EXE! _ Kscbt + 7237)

0 × 82e3cf (ORACLE. EXE! _ KksParseCursor + 2099)

0 × 82f1b8 (ORACLE. EXE! _ Kksxsccompat + 148)

0 × 201683e (ORACLE. EXE! _ Opibrp + 1970)

0 × 13cd5ed (ORACLE. EXE! _ Kpodrd + 237)

0 × 13cba7c (ORACLE. EXE! _ Kpocrs + 780)

0 × 85174e (ORACLE. EXE! _ Opirip + 1102)

0 × 60feff90 (oracommon10.dll! _ Ttcpro + 1276)

0 × 850a69 (ORACLE. EXE! _ Opiodr + 1017)

0 × 1221350 (ORACLE. EXE! _ Opiino3 + 1092)

0 × 85174e (ORACLE. EXE! _ Opirip + 1102)

0 × 420e58 (ORACLE. EXE! _ Opidcl + 824)

0 × 42164a (ORACLE. EXE! _ Ksdwri + 50)

0 × 401171 (ORACLE. EXE! _ Ssthrnfy + 117)

0 × 401061 (ORACLE. EXE! _ Opimai_init + 97)

0 × 401905 (ORACLE. EXE! _ Osnsoiint + 713)

0 × 7c80b729 (KERNEL32.dll! GetModuleFileNameA + 442)

[Args (6)]:

0 × 81e58d0

0 × 81e5da8

0

0 × 40a03000

0 × 8559500

0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.