Saturday, October 25, 2008

useful scripts

- In this post ,I will put several tiny tiny scripts, which will be useful for many developers...most of these scripts are avaiable in books, different places in the oracle world , metalink..but this is an attempt to create a group of scripts which will be helpful to oracle developers and performance tuniners..
1) How to get a formatted easiet ( in my experience) explain plan : - Source of this script is
askTom - http://asktom.oracle.com/pls/asktom/f?p=100:1:3230070367714767

set serveroutput on size 1000000
column plan_plus_exp format a108 ( You can increase it as per your requirements)
set linesize 131 ( You can increase/decrease it as per your requirements)
set autotrace traceonly explain
--Here goes your SQL

and thats it...you will see the nice explain plan
2) How to turn the trace on and locate your tracefile in a easy way
alter session set tracefile_identifier='abc' ;
alter session set statistics_level = 'ALL' ;
alter session set sql_trace=true ;
--run your SQL or program

then
exit ;
the go to your udump directoy ( to see it from SQL plus - use show parameter udump )

and there look for ls -lrt *abc*.trc and thats it.

also to take a trace of level 12 then please use this
alter session set events '10046 trace name context forever, level 12';
- How to see chained rows count
select chain_cnt from user_tables where table_name = 'T';
Thank You and Please feel free to add the scripts in this repository.

No comments: