0% found this document useful (0 votes)
34 views

Bind Variable Using Tkprof

1. The document traces the execution of three SQL queries that select from the dept1 table using different bind variables or literals for the deptno column. 2. The first query uses a bind variable set to 10, resulting in a hard parse due to the bind variable. The second and third queries use literals of 20 and 30, resulting in soft parses from the library cache. 3. Statistics are reported for each query execution including parse time, execution time, disk reads, buffer gets, and rows processed. All queries result in a full table scan of the dept1 table to return 8 rows.

Uploaded by

Suditya Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Bind Variable Using Tkprof

1. The document traces the execution of three SQL queries that select from the dept1 table using different bind variables or literals for the deptno column. 2. The first query uses a bind variable set to 10, resulting in a hard parse due to the bind variable. The second and third queries use literals of 20 and 30, resulting in soft parses from the library cache. 3. Statistics are reported for each query execution including parse time, execution time, disk reads, buffer gets, and rows processed. All queries result in a full table scan of the dept1 table to return 8 rows.

Uploaded by

Suditya Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

conn aa/aa

1.alter session set sql_trace=true


2.variable x number;
3.begin
:x:=10;
end;
/
4.select *
from
dept1 where deptno=:x;

5.select *
from
dept1 where deptno=20;
6.select *
from
dept1 where deptno=30;

7.alter session set sql_trace=false;

8. go to udump directory ...


9. ls -lrt
10.tkprof rman_ora_25657.trc output_aa.lst explain=aa/aa sys=no

********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************

********************************************************************************

select *
from
dept1 where deptno=:x

call count cpu elapsed disk query current rows


------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 4 0 0
Fetch 2 0.00 0.00 0 4 0 8
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 8 0 8

Misses in library cache during parse: 1 /*note hard parsing */


Optimizer mode: ALL_ROWS
Parsing user id: 65 (AA)

Rows Row Source Operation


------- ---------------------------------------------------
8 TABLE ACCESS FULL DEPT1 (cr=4 pr=0 pw=0 time=63 us)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
8 TABLE ACCESS (FULL) OF 'DEPT1' (TABLE)

********************************************************************************
********************************************************************************

select *
from
dept1 where deptno=20

call count cpu elapsed disk query current rows


------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 4 0 8
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 4 0 8

Misses in library cache during parse: 0 /*note soft parsing */


Optimizer mode: ALL_ROWS
Parsing user id: 65 (AA)

Rows Row Source Operation


------- ---------------------------------------------------
8 TABLE ACCESS FULL DEPT1 (cr=4 pr=0 pw=0 time=74 us)

Rows Execution Plan


------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
8 TABLE ACCESS (FULL) OF 'DEPT1' (TABLE)

********************************************************************************

select *
from
dept1 where deptno=30

call count cpu elapsed disk query current rows


------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 4 0 8
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 4 0 8

Misses in library cache during parse: 0 /*note soft parsing */


Optimizer mode: ALL_ROWS
Parsing user id: 65 (AA)

Rows Row Source Operation


------- ---------------------------------------------------
8 TABLE ACCESS FULL DEPT1 (cr=4 pr=0 pw=0 time=91 us)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
8 TABLE ACCESS (FULL) OF 'DEPT1' (TABLE)

********************************************************************************

291,1 73%

You might also like