<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-10040867</id><updated>2011-04-21T11:58:10.157-07:00</updated><title type='text'>James's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>75</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-10040867.post-114065224907676441</id><published>2006-02-22T15:34:00.000-08:00</published><updated>2006-02-22T15:50:49.090-08:00</updated><title type='text'>Oracle: wait events</title><content type='html'>&lt;strong&gt;log file sync:&lt;/strong&gt; is a client wait event.  It is the wait event your clients wait on when they say "commit".  It is the wait for LGWR to actually write their redo to disk and return back to them.  You can "tune" this by making lgwr faster (no raid 5 for example) and committing less frequently and generating less redo (BULK operations generate less redo than row by row do)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;LGWR wait for redo copy:&lt;/strong&gt; is a background wait. LGWR is waiting for forgrounds to finish a current copy affecting the data LGWR is about to process.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;enqueue:&lt;/strong&gt; is your wait and that is all about application design - those are heavyweight locks induced by the application logic itself.  You would be best served by looking at the *application* not at the "system" at this point.&lt;br /&gt;do a level 12 10046 trace event on your application and see what it is truly waiting for.  it is all about tuning the application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-114065224907676441?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/114065224907676441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=114065224907676441' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114065224907676441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114065224907676441'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-wait-events.html' title='Oracle: wait events'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-114041700119990997</id><published>2006-02-19T22:29:00.000-08:00</published><updated>2006-02-19T22:30:01.213-08:00</updated><title type='text'>Oracle: v$bh - who is using buffer cache?</title><content type='html'>column c0 heading 'Owner'                     format a15&lt;br /&gt;column c1 heading 'ObjectName'               format a30&lt;br /&gt;column c2 heading 'NumberofBuffers'         format 999,999&lt;br /&gt;column c3 heading 'Percentageof DataBuffer' format 999,999,999&lt;br /&gt; &lt;br /&gt;select&lt;br /&gt;   owner                        c0,&lt;br /&gt;   object_name                  c1,&lt;br /&gt;   count(1)                     c2,&lt;br /&gt;   (count(1)/(select count(*) from v$bh)) *100  c3&lt;br /&gt;from&lt;br /&gt;   dba_objects o,&lt;br /&gt;   v$bh        bh&lt;br /&gt;where&lt;br /&gt;   o.object_id  = bh.objd&lt;br /&gt;and&lt;br /&gt;   o.owner not in ('SYS','SYSTEM','AURORA$JIS$UTILITY$')&lt;br /&gt;group by&lt;br /&gt;   owner,&lt;br /&gt;   object_name&lt;br /&gt;order by&lt;br /&gt;   count(1) desc&lt;br /&gt;;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-114041700119990997?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/114041700119990997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=114041700119990997' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114041700119990997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114041700119990997'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-vbh-who-is-using-buffer-cache.html' title='Oracle: v$bh - who is using buffer cache?'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-114006681616925023</id><published>2006-02-15T21:06:00.000-08:00</published><updated>2006-02-15T21:13:36.186-08:00</updated><title type='text'>Oracle: Bulk Collect</title><content type='html'>DECLARE&lt;br /&gt;&lt;a name="18527"&gt;&lt;/a&gt;   TYPE EmpCurTyp IS REF CURSOR;&lt;br /&gt;&lt;a name="18502"&gt;&lt;/a&gt;   TYPE NumList IS TABLE OF NUMBER;&lt;br /&gt;&lt;a name="18496"&gt;&lt;/a&gt;   TYPE NameList IS TABLE OF VARCHAR2(15);&lt;br /&gt;&lt;a name="18467"&gt;&lt;/a&gt;   emp_cv EmpCurTyp;&lt;br /&gt;&lt;a name="18415"&gt;&lt;/a&gt;   empnos NumList;&lt;br /&gt;&lt;a name="18517"&gt;&lt;/a&gt;   enames NameList;&lt;br /&gt;&lt;a name="18416"&gt;&lt;/a&gt;   sals NumList;&lt;br /&gt;&lt;a name="17400"&gt;&lt;/a&gt;BEGIN&lt;br /&gt;&lt;a name="17401"&gt;&lt;/a&gt;   OPEN emp_cv FOR 'SELECT empno, ename FROM emp';&lt;br /&gt;&lt;a name="18431"&gt;&lt;/a&gt;   FETCH emp_cv BULK COLLECT INTO empnos, enames;&lt;br /&gt;&lt;a name="18432"&gt;&lt;/a&gt;   CLOSE emp_cv;&lt;br /&gt;&lt;a name="18494"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="18433"&gt;&lt;/a&gt;   EXECUTE IMMEDIATE 'SELECT sal FROM emp'&lt;br /&gt;&lt;a name="18434"&gt;&lt;/a&gt;        BULK COLLECT INTO sals;&lt;br /&gt;&lt;a name="17403"&gt;&lt;/a&gt;END;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--- only insert/update/delete can have output bind variables.&lt;br /&gt;--- to bulk-bind them, use BULK RETURNING INTO clause in an EXECUTE IMMEDIATE.&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;&lt;a name="18577"&gt;&lt;/a&gt;   TYPE NameList IS TABLE OF VARCHAR2(15);&lt;br /&gt;&lt;a name="18580"&gt;&lt;/a&gt;   enames NameList;&lt;br /&gt;&lt;a name="17409"&gt;&lt;/a&gt;   bonus_amt NUMBER := 500;&lt;br /&gt;&lt;a name="18588"&gt;&lt;/a&gt;   sql_stmt VARCHAR(200);&lt;br /&gt;&lt;a name="17410"&gt;&lt;/a&gt;BEGIN&lt;br /&gt;&lt;a name="17411"&gt;&lt;/a&gt;   sql_stmt := 'UPDATE emp SET bonus = :1 RETURNING ename INTO :2';&lt;br /&gt;&lt;a name="18441"&gt;&lt;/a&gt;   EXECUTE IMMEDIATE sql_stmt&lt;br /&gt;&lt;a name="18442"&gt;&lt;/a&gt;   USING bonus_amt RETURNING BULK COLLECT INTO enames;&lt;br /&gt;&lt;a name="17412"&gt;&lt;/a&gt;END;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-114006681616925023?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/114006681616925023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=114006681616925023' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114006681616925023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114006681616925023'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-bulk-collect.html' title='Oracle: Bulk Collect'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-114006499482960391</id><published>2006-02-15T20:38:00.000-08:00</published><updated>2006-02-15T20:44:42.166-08:00</updated><title type='text'>Oracle: binding variable or non-binding variable</title><content type='html'>No-bind&lt;br /&gt;--------------&lt;br /&gt;set timing on&lt;br /&gt;declare&lt;br /&gt;x number;&lt;br /&gt;begin&lt;br /&gt;for i in 1 .. 50000 loop&lt;br /&gt;execute immediate&lt;br /&gt;'select count(*) from dual where dummy = 'i into x;&lt;br /&gt;end loop;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;with-bind&lt;br /&gt;---------------&lt;br /&gt;set timing on&lt;br /&gt;declare&lt;br /&gt;x number;&lt;br /&gt;begin&lt;br /&gt;for i in 1 .. 50000 loop&lt;br /&gt;select count(*) into x from dual where dummy = i;&lt;br /&gt;end loop;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;select count(*) into x from dual where dummy = :i using i;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-114006499482960391?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/114006499482960391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=114006499482960391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114006499482960391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/114006499482960391'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-binding-variable-or-non-binding.html' title='Oracle: binding variable or non-binding variable'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113996353026504586</id><published>2006-02-14T16:06:00.000-08:00</published><updated>2006-02-14T16:32:10.280-08:00</updated><title type='text'>Oracle: DBMS_SYSTEM Package</title><content type='html'>1) ksdwrt&lt;br /&gt;exec dbms_system.ksdwrt(n, message);&lt;br /&gt;"n" indicates the destination&lt;br /&gt;  1 - write to trace file&lt;br /&gt;  2 - write to alert log&lt;br /&gt;  3 - write to both&lt;br /&gt;&lt;br /&gt;2) set_sql_trace_in_session&lt;br /&gt;exec dbms_system.set_sql_trace_in_session(sid, serial#, true);&lt;br /&gt;&lt;br /&gt;3) set_ev&lt;br /&gt;exec dbms_system.set_ev(sid,serial#, event, level, name);&lt;br /&gt;exec dbms_system.set_ev(31, 97, 10046, 4, '');&lt;br /&gt;level indicates:&lt;br /&gt;  1 - standard sql_trace functionality.&lt;br /&gt;  4 - as level 1 plus tracing of bind variables&lt;br /&gt;  8 - as level 1 plus wait events&lt;br /&gt;  12 - as level1 plus bind variables and wait events.&lt;br /&gt;&lt;br /&gt;4) read_ev&lt;br /&gt;exec dbms_system.read_ev(event,output);&lt;br /&gt;if output = 1 the event is being traced.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113996353026504586?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113996353026504586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113996353026504586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113996353026504586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113996353026504586'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-dbmssystem-package.html' title='Oracle: DBMS_SYSTEM Package'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113995467847644065</id><published>2006-02-14T13:47:00.000-08:00</published><updated>2006-02-14T14:04:38.493-08:00</updated><title type='text'>Oracle: time/date operation</title><content type='html'>1. date interval&lt;br /&gt;&lt;br /&gt;select sysdate, sysdate - interval '7' MINUTE from dual&lt;br /&gt;&lt;br /&gt;select sysdate, sysdate - interval '7' day from dual&lt;br /&gt;&lt;br /&gt;select sysdate, sysdate - 8*interval '2' hour from dual&lt;br /&gt;&lt;br /&gt;2. date to char conversion&lt;br /&gt;select sysdate, to_char(sysdate, 'yyy-mm-dd hh24:mi:ss') from dual&lt;br /&gt;&lt;br /&gt;3. char to date conversion&lt;br /&gt;select to_date('2005-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual&lt;br /&gt;&lt;br /&gt;4. trunk/round functions&lt;br /&gt;select trunc(sysdate,'YEAR') from dual&lt;br /&gt;&lt;br /&gt;5. using mili-second date type&lt;br /&gt;select to_char(current_timestamp(9),'HH24:MI:SSxFF') from dual&lt;br /&gt;&lt;br /&gt;6. calculate process runtime&lt;br /&gt;declare&lt;br /&gt;  type rc is ref cursor;&lt;br /&gt;  l_rc rc;&lt;br /&gt;  l_dummy all_objects.object_name%type;&lt;br /&gt;begin&lt;br /&gt;  for i in 1 .. 1000&lt;br /&gt;  loop&lt;br /&gt;    open l_rc for 'select object_name from all_objects '&lt;br /&gt;                           'where object_id = ' i;&lt;br /&gt;    fetch l_rc into l_dummy;&lt;br /&gt;    close l_rc;&lt;br /&gt;  end loop;&lt;br /&gt;  dbms_output.put_line&lt;br /&gt;       (round( ( dbms_utility.get_time-l_start)/100, 2)  ' seconds...');&lt;br /&gt;end;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113995467847644065?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113995467847644065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113995467847644065' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113995467847644065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113995467847644065'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-timedate-operation.html' title='Oracle: time/date operation'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113987587659172212</id><published>2006-02-13T16:10:00.000-08:00</published><updated>2006-02-13T16:11:16.616-08:00</updated><title type='text'>Oracle: how to skip bad block</title><content type='html'>First thing you need to do is find the bad block ids. To do this you can run dbverify. Lets assume our block id is 1234 .&lt;br /&gt;&lt;br /&gt;Now find the segment name by running this query&lt;br /&gt;select segment_name, segment_type, block_id, blocks from dba_extents where (1234 between block_id and (block_id + blocks - 1))&lt;br /&gt;&lt;br /&gt;Once you have the bad segment name, its better to create a temporary table with good data if the segment is a table. If the segment is an index, drop the index and recreate it.&lt;br /&gt;create table good_table as select * from bad_table where rowid not in ( select /*+index(bad_table, any_index)*/ rowid from bad_table where substr( rowid, 1, 8 ) = 1234)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113987587659172212?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113987587659172212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113987587659172212' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113987587659172212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113987587659172212'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-how-to-skip-bad-block.html' title='Oracle: how to skip bad block'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113987460529775617</id><published>2006-02-13T15:42:00.000-08:00</published><updated>2006-02-13T15:50:05.310-08:00</updated><title type='text'>Oracle: Oradebug - view bind value</title><content type='html'>1) get sid&lt;br /&gt;select username,sid,serial#&lt;br /&gt;from  v$session&lt;br /&gt;where audsid = userenv('sessionid');&lt;br /&gt;&lt;br /&gt;2) oradebug setorapid 15&lt;br /&gt;     oradebug EVENT 10046 trace name context forever,level 12&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113987460529775617?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113987460529775617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113987460529775617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113987460529775617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113987460529775617'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-oradebug-view-bind-value.html' title='Oracle: Oradebug - view bind value'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113951147215426386</id><published>2006-02-09T10:53:00.000-08:00</published><updated>2006-02-09T10:59:16.196-08:00</updated><title type='text'>Java: GC tunning</title><content type='html'>&lt;a href="http://www.petefreitag.com/articles/gctuning/"&gt;http://www.petefreitag.com/articles/gctuning/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3.2 The Young Generation&lt;br /&gt;The bigger the young generation the less minor GC's, but this implies a smaller tenured generation which increases the frequency of major collections.&lt;br /&gt;You need to look at your application and determine how long your objects live for to tune this.&lt;br /&gt;-XX:NewRatio=3 - the young generation will occupy 1/4 the overall heap&lt;br /&gt;-XX:NewSize - Size of the young generation at JVM init. Calculated automatically if you specify -XX:NewRatio&lt;br /&gt;-XX:MaxNewSize - The largest size the young generation can grow to (unlimited if this value is not specified at command line)&lt;br /&gt;&lt;br /&gt;4 Types of Collectors&lt;br /&gt;Everything to this point talks about the default garbage collector, there are other GC's you can use&lt;br /&gt;Throughput Collector - Uses a parallel version of the young generation collector&lt;br /&gt;-XX:+UseParallelGC&lt;br /&gt;Tenured collector is the same as in default&lt;br /&gt;Concurrent Low Pause Collector&lt;br /&gt;Collects tenured collection concurrently with the execution of the app.&lt;br /&gt;The app is paused for short periods during collection&lt;br /&gt;-XX:+UseConcMarkSweepGC&lt;br /&gt;To enable a parallel young generation GC with the concurrent GC add -XX:+UseParNewGC to the startup. Don't add -XX:+UseParallelGC with this option.&lt;br /&gt;Incremental Low Pause Collector&lt;br /&gt;Sometimes called Train Collector&lt;br /&gt;Collects a portion of the tenured generation at each minor collection.&lt;br /&gt;Tries to minimize large pause of major collections&lt;br /&gt;Slower than the default collector when considering overall throughput&lt;br /&gt;Good for client apps (my observation)&lt;br /&gt;-Xincgc&lt;br /&gt;Don't mix these options, JVM may not behave as expected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113951147215426386?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113951147215426386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113951147215426386' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113951147215426386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113951147215426386'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/java-gc-tunning.html' title='Java: GC tunning'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113944261351451159</id><published>2006-02-08T15:43:00.000-08:00</published><updated>2006-02-09T10:00:28.620-08:00</updated><title type='text'>Oracle: Runtime Row Source Statistics</title><content type='html'>9iR2 introduces dynamic performance table: v$sql_plan_statistics.&lt;br /&gt;it provides for each cached cursor the execution statistics of &lt;br /&gt;each operation in the execution plan.&lt;br /&gt;to use this view, parameter STATISTICS_LEVEL must be set to ALL.&lt;br /&gt;&lt;br /&gt;additional information, see &lt;br /&gt;&lt;br /&gt;v$sql_plan&lt;br /&gt;v$sql_plan_statistics_all&lt;br /&gt;v$sql_workarea ( contains memory usage statistics for row sources that use sql memory, for instance, hash-join and sort)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;• v$sql_plan - This view shows the same information as shown by Explain Plan except it is the actual execution plan and not the predicted one – just like tkprof and even better than Explain Plan. &lt;br /&gt;&lt;br /&gt;• v$sql_plan_statistics - This view contains the execution statistics for each operation (step) in the v$sql_plan. Queries should access this view and look for poor SQL operations including TABLE ACCESS FULL – full-table scans.&lt;br /&gt;&lt;br /&gt;• v$sql_plan_statistics_all - This view combines data from v$sql_plan, v$sql_plan_statistics and v$sql_workarea. &lt;br /&gt;&lt;br /&gt;Both v$sql_plan_statistics and v$sql_plan_statistics_all are not populated by default. The option statistics_level=all must be set.&lt;br /&gt;Or turn on sql_trace will also populates these views.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113944261351451159?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113944261351451159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113944261351451159' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113944261351451159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113944261351451159'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-runtime-row-source-statistics.html' title='Oracle: Runtime Row Source Statistics'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113944219618352777</id><published>2006-02-08T15:41:00.000-08:00</published><updated>2006-02-08T15:43:16.200-08:00</updated><title type='text'>Oracle: 9i segment level statistics</title><content type='html'>9i release 2 and higher,&lt;br /&gt;segment statistics could be retrieved from following views.&lt;br /&gt;&lt;br /&gt;v$segment_statistics&lt;br /&gt;v$segstat&lt;br /&gt;v$segstat_name&lt;br /&gt;&lt;br /&gt;select owner, object_name,statistic_name,value&lt;br /&gt;from v$segment_statistics&lt;br /&gt;where owner='SYSTEM'&lt;br /&gt;and object_name='TABLE'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113944219618352777?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113944219618352777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113944219618352777' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113944219618352777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113944219618352777'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-9i-segment-level-statistics.html' title='Oracle: 9i segment level statistics'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113934039402789486</id><published>2006-02-07T11:04:00.000-08:00</published><updated>2006-02-07T11:26:34.043-08:00</updated><title type='text'>Perl: references of array/hash/scalar</title><content type='html'># create variables&lt;br /&gt;$a     =  "world";&lt;br /&gt;@array =  (10,20,30);&lt;br /&gt;%hash  =  ("james"=&gt;"pei", "lisa"=&gt;"han");&lt;br /&gt;&lt;br /&gt;# create references to them&lt;br /&gt;$ra    =  \$a;&lt;br /&gt;$rarray=  \@array;&lt;br /&gt;$rhash =  \%hash;&lt;br /&gt;&lt;br /&gt;# create references to constant scalars&lt;br /&gt;$ra    = \10;&lt;br /&gt;$rs    = \"hello world";&lt;br /&gt;&lt;br /&gt;# references to scalars&lt;br /&gt;$ra = \$a;&lt;br /&gt;$$ra += 2;&lt;br /&gt;print $$ra;&lt;br /&gt;&lt;br /&gt;# references to Hashes&lt;br /&gt;$rhash = \%hash;&lt;br /&gt;print $rhash-&gt;{"key1"};&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113934039402789486?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113934039402789486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113934039402789486' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113934039402789486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113934039402789486'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/perl-references-of-arrayhashscalar.html' title='Perl: references of array/hash/scalar'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113910409890996537</id><published>2006-02-04T17:47:00.000-08:00</published><updated>2006-02-04T17:48:18.923-08:00</updated><title type='text'>Oracle: Hit Radio</title><content type='html'>Buffer Hit Ratio&lt;br /&gt;BUFFER HIT RATIO NOTES:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Consistent Gets - The number of accesses made to the block buffer to retrieve data in a consistent mode. &lt;br /&gt;DB Blk Gets - The number of blocks accessed via single block gets (i.e. not through the consistent get mechanism). &lt;br /&gt;Physical Reads - The cumulative number of blocks read from disk. &lt;br /&gt;&lt;br /&gt;Logical reads are the sum of consistent gets and db block gets. &lt;br /&gt;The db block gets statistic value is incremented when a block is read for update and when segment header blocks are accessed. &lt;br /&gt;Hit Ratio should be &gt; 80%, else increase DB_BLOCK_BUFFERS in init.ora &lt;br /&gt;&lt;br /&gt;select  sum(decode(NAME, 'consistent gets',VALUE, 0)) "Consistent Gets",&lt;br /&gt; sum(decode(NAME, 'db block gets',VALUE, 0)) "DB Block Gets",&lt;br /&gt; sum(decode(NAME, 'physical reads',VALUE, 0)) "Physical Reads",&lt;br /&gt; round((sum(decode(name, 'consistent gets',value, 0)) + &lt;br /&gt;        sum(decode(name, 'db block gets',value, 0)) - &lt;br /&gt;        sum(decode(name, 'physical reads',value, 0))) / &lt;br /&gt;       (sum(decode(name, 'consistent gets',value, 0)) + &lt;br /&gt;        sum(decode(name, 'db block gets',value, 0))) * 100,2) "Hit Ratio"&lt;br /&gt;from   v$sysstat&lt;br /&gt;&lt;br /&gt;Data Dict Hit Ratio&lt;br /&gt;DATA DICTIONARY HIT RATIO NOTES:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Gets - Total number of requests for information on the data object. &lt;br /&gt;Cache Misses - Number of data requests resulting in cache misses &lt;br /&gt;&lt;br /&gt;Hit Ratio should be &gt; 90%, else increase SHARED_POOL_SIZE in init.ora &lt;br /&gt;&lt;br /&gt;select  sum(GETS),&lt;br /&gt; sum(GETMISSES),&lt;br /&gt; round((1 - (sum(GETMISSES) / sum(GETS))) * 100,2)&lt;br /&gt;from  v$rowcache&lt;br /&gt;&lt;br /&gt;SQL Cache Hit Ratio&lt;br /&gt;SQL CACHE HIT RATIO NOTES:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Pins - The number of times a pin was requested for objects of this namespace. &lt;br /&gt;Reloads - Any pin of an object that is not the first pin performed since the object handle was created, and which requires loading the object from disk. &lt;br /&gt;&lt;br /&gt;Hit Ratio should be &gt; 85% &lt;br /&gt;&lt;br /&gt;select  sum(PINS) Pins,&lt;br /&gt; sum(RELOADS) Reloads,&lt;br /&gt; round((sum(PINS) - sum(RELOADS)) / sum(PINS) * 100,2) Hit_Ratio&lt;br /&gt;from  v$librarycache&lt;br /&gt;&lt;br /&gt;Library Cache Miss Ratio&lt;br /&gt;LIBRARY CACHE MISS RATIO NOTES:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Executions - The number of times a pin was requested for objects of this namespace. &lt;br /&gt;Cache Misses - Any pin of an object that is not the first pin performed since the object handle was created, and which requires loading the object from disk. &lt;br /&gt;&lt;br /&gt;Hit Ratio should be &lt; 1%, else increase SHARED_POOL_SIZE in init.ora &lt;br /&gt;&lt;br /&gt;select  sum(PINS) Executions,&lt;br /&gt; sum(RELOADS) cache_misses,&lt;br /&gt; sum(RELOADS) / sum(PINS) miss_ratio&lt;br /&gt;from  v$librarycache&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113910409890996537?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113910409890996537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113910409890996537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113910409890996537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113910409890996537'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-hit-radio.html' title='Oracle: Hit Radio'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113891827265456136</id><published>2006-02-02T14:10:00.000-08:00</published><updated>2006-02-02T14:11:12.670-08:00</updated><title type='text'>Oracle: DBWn or DB Slaves</title><content type='html'>To determine whether to use multiple DBWn processes or database slaves, follow these guidelines:&lt;br /&gt;&lt;br /&gt;1) For write intensive applications that also have a large data buffer cache (100,000 and up), configure DB_WRITER_PROCESSES &lt;br /&gt;&lt;br /&gt;2) For applications that are not write intensive and run on operating systems that support asynchronous I/O, configure DBWR_IO_SLAVES &lt;br /&gt;&lt;br /&gt;3) If the operating system does not support asnychronous I/O, use DBWR_IO_SLAVES &lt;br /&gt;&lt;br /&gt;4) If your server only has one CPU, use DBWR_IO_SLAVES, DBWR processes are CPU intensive&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113891827265456136?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113891827265456136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113891827265456136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113891827265456136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113891827265456136'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/oracle-dbwn-or-db-slaves.html' title='Oracle: DBWn or DB Slaves'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113884210897596318</id><published>2006-02-01T17:00:00.000-08:00</published><updated>2006-02-01T17:01:48.986-08:00</updated><title type='text'>UNIX: Sendmail</title><content type='html'>to test relay using telnet&lt;br /&gt;========================================&lt;br /&gt;&lt;br /&gt;helo cland.com&lt;br /&gt;250 gsc6.gv.synnex.net Hello cland.com (192.168.7.7)&lt;br /&gt;mail from:&lt;peij@yahoo.com&gt;&lt;br /&gt;250 sender ok &lt;peij@yahoo.com&gt;&lt;br /&gt;RCPT TO:&lt;kcyao@hotmail.com&gt;&lt;br /&gt;250 Recipient ok &lt;kcyao@hotmail.com&gt;&lt;br /&gt;DATA&lt;br /&gt;354 send the mail data, end with .&lt;br /&gt;Subject: this is a test&lt;br /&gt;this is a test&lt;br /&gt;.&lt;br /&gt;exit&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113884210897596318?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113884210897596318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113884210897596318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113884210897596318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113884210897596318'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/02/unix-sendmail.html' title='UNIX: Sendmail'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113875096903886409</id><published>2006-01-31T15:41:00.000-08:00</published><updated>2006-01-31T15:44:52.466-08:00</updated><title type='text'>Oracle: merge tables</title><content type='html'>merge combined insert and update into one command&lt;br /&gt;&lt;br /&gt;merge into EMP e1&lt;br /&gt;using EXTERNAL_TABLE e2&lt;br /&gt;on ( e2.empno = e1.empno )&lt;br /&gt;when matched then&lt;br /&gt;    update set e1.sal = e2.sal&lt;br /&gt;when not matched then&lt;br /&gt;    insert ( empno, ename, job, mgr, hiredate, sal, comm, deptno )&lt;br /&gt;    values ( e2.empno, e2.ename, e2.job, e2.mgr, e2.hiredate, e2.sal, e2.comm, &lt;br /&gt;e2.deptno )&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Doing a direct path load would simply be:&lt;br /&gt;&lt;br /&gt;insert /*+ append */ into emp select * from external_table;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;create external table from a flat text file&lt;br /&gt;&lt;br /&gt;create or replace directory data_dir as 'c:\temp\'&lt;br /&gt;&lt;br /&gt;create table external_table&lt;br /&gt;(EMPNO NUMBER(4) ,&lt;br /&gt; ENAME VARCHAR2(10),&lt;br /&gt; JOB VARCHAR2(9),&lt;br /&gt; MGR NUMBER(4),&lt;br /&gt; HIREDATE DATE,&lt;br /&gt; SAL NUMBER(7, 2),&lt;br /&gt; COMM NUMBER(7, 2),&lt;br /&gt; DEPTNO NUMBER(2)&lt;br /&gt;)&lt;br /&gt;ORGANIZATION EXTERNAL&lt;br /&gt;( type oracle_loader&lt;br /&gt;  default directory data_dir&lt;br /&gt;  access parameters&lt;br /&gt;  ( fields terminated by ',' )&lt;br /&gt;  location ('emp.dat')&lt;br /&gt;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113875096903886409?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113875096903886409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113875096903886409' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113875096903886409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113875096903886409'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-merge-tables.html' title='Oracle: merge tables'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113874988716699168</id><published>2006-01-31T15:23:00.000-08:00</published><updated>2006-01-31T15:24:47.176-08:00</updated><title type='text'>Oracle: fetch across commit</title><content type='html'>for x in ( select rowid rid, t.* from T ) loop&lt;br /&gt;     update T set x = x+1 where rowid = x.rid;&lt;br /&gt;     commit;&lt;br /&gt;  end loop;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That implicit cursor is fetched from "across a commit".  It is the practice of &lt;br /&gt;keeping a cursor open after committing.  It is a bad practice and is a common &lt;br /&gt;cause of ORA-1555 (the above looping construct in particular)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113874988716699168?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113874988716699168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113874988716699168' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113874988716699168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113874988716699168'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-fetch-across-commit.html' title='Oracle: fetch across commit'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113867288273684258</id><published>2006-01-30T18:01:00.000-08:00</published><updated>2006-01-30T18:01:22.746-08:00</updated><title type='text'>Oracle: Histogram-2</title><content type='html'>Remember, analyzing for histograms is time-consuming, and histograms are used under two conditions:&lt;br /&gt;&lt;br /&gt;    *&lt;br /&gt;      Table join order – The CBO must know the size of the intermediate result sets (cardinality) to properly determine the correct join order the multi-table joins.&lt;br /&gt;       &lt;br /&gt;    *&lt;br /&gt;      Table access method – The CBO needs to know about columns in SQL where clauses, where the column value is skewed such that a full-table scan might be faster than an index range scan. Oracle uses this skew information in conjunction with the clustering_factor columns of the dba_indexes view.&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;Hence, this is the proper order for using the dbms_stats package to locate proper columns for histograms:&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    1. Skewonly option - You want to use skewonly to do histograms for skewed columns, for cases where the value will make a difference between a full-table scan and an index scan.&lt;br /&gt;&lt;br /&gt;    2. Monitor - Next, turn-on monitoring. Issue an “alter table xx monitoring” and “alter index yyy monitoring” command for all segments in your schema. This will monitor workload against&lt;br /&gt;&lt;br /&gt;    3. Auto option - Once monitoring is in-place, you need to re-analyze with the "auto" option to create histograms for join columns within tables. This is critical for the CBO to determine the proper join order for finding the driving table in multi-table joins.&lt;br /&gt;&lt;br /&gt;    4. Repeat option - Finally, use the "repeat" option to re-analyze only the existing histograms.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113867288273684258?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113867288273684258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113867288273684258' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113867288273684258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113867288273684258'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-histogram-2.html' title='Oracle: Histogram-2'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113867097297981778</id><published>2006-01-30T17:27:00.000-08:00</published><updated>2006-01-30T17:29:33.000-08:00</updated><title type='text'>Oracle: Histogram-1</title><content type='html'>A new feature of the dbms_stats package is the ability to look for columns that should have histograms, and then automatically create the histograms. Oracle introduced some new method_opt parameter options for the dbms_stats package. These new options are auto, repeat and skewonly and are coded as follows:&lt;br /&gt;&lt;br /&gt; method_opt=&gt;'for all columns size auto'&lt;br /&gt; method_opt=&gt;'for all columns size repeat'&lt;br /&gt; method_opt=&gt;'for all columns size skewonly'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; The auto option is used only when monitoring has been invoked via the alter table…monitoring command. Histograms are created based upon both the data distribution (see Figure A) and the workload on the column as determined by monitoring, like this.&lt;br /&gt;&lt;br /&gt; execute dbms_stats.gather_schema_stats(&lt;br /&gt; ownname          =&gt; 'SCOTT',&lt;br /&gt; estimate_percent =&gt; DBMS_STATS.AUTO_SAMPLE_SIZE,&lt;br /&gt; method_opt       =&gt; 'for all columns size auto',&lt;br /&gt; degree           =&gt; DBMS_STATS.DEFAULT_DEGREE);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Using the repeat option, histograms are collected only on the columns that already have histograms. Histograms are static, like any other CBO statistic, and need to be refreshed when column value distributions change. The repeat option would be used when refreshing statistics, as in this example:&lt;br /&gt;&lt;br /&gt;execute dbms_stats.gather_schema_stats(&lt;br /&gt; ownname          =&gt; 'SCOTT',&lt;br /&gt; estimate_percent =&gt; DBMS_STATS.AUTO_SAMPLE_SIZE,&lt;br /&gt; method_opt       =&gt; 'for all columns size repeat',&lt;br /&gt; degree           =&gt; DBMS_STATS.DEFAULT_DEGREE);&lt;br /&gt;&lt;br /&gt; The skewonly option introduces a very time-consuming build process because it examines the data distribution of values for every column within every index. When the dbms_stats package finds an index whose column values are distributed unevenly, it creates histograms to help the CBO make a table access decision (i.e., index versus a full-table scan). From the earlier vehicle_type example, if an index has one column value (e.g., CAR) that exists in 65 percent of the rows, a full-table scan will be faster than an index scan to access those rows, as in this example:&lt;br /&gt;&lt;br /&gt;execute dbms_stats.gather_schema_stats(&lt;br /&gt; ownname          =&gt; 'SCOTT',&lt;br /&gt; estimate_percent =&gt; DBMS_STATS.AUTO_SAMPLE_SIZE,&lt;br /&gt; method_opt      =&gt; 'for all columns size skewonly',&lt;br /&gt; degree           =&gt; DBMS_STATS.DEFAULT_DEGREE);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113867097297981778?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113867097297981778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113867097297981778' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113867097297981778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113867097297981778'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-histogram-1.html' title='Oracle: Histogram-1'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113865470638324263</id><published>2006-01-30T12:25:00.000-08:00</published><updated>2006-01-30T12:58:26.406-08:00</updated><title type='text'>Oracle: PL/SQL interval datatype</title><content type='html'>Old fashion way:&lt;br /&gt;&lt;br /&gt;   declare&lt;br /&gt;     begin_2000 date :=  to_date('1-Jan-2000','dd-Mon-yyyy');&lt;br /&gt;     begin_2001 date :=  to_date('1-Jan-2001','dd-Mon-yyyy');&lt;br /&gt;     days_in_2000 number;&lt;br /&gt;   begin&lt;br /&gt;     days_in_2000 := begin_2001 - begin_2000;&lt;br /&gt;     dbms_output.put_line(days_in_2000);&lt;br /&gt;   end;&lt;br /&gt;&lt;br /&gt;To advance a DATE to the next day, you add 1; to advance a DATE by 1 hour, you add 1/24; and so forth.&lt;br /&gt;&lt;br /&gt;New interval datatype:&lt;br /&gt;&lt;br /&gt;DECLARE &lt;br /&gt;   begin_2000 TIMESTAMP := TO_TIMESTAMP('1-Jan-2000','dd-Mon-yyyy');&lt;br /&gt;   begin_2001 TIMESTAMP := TO_TIMESTAMP('1-Jan-2001','dd-Mon-yyyy');&lt;br /&gt;   days_in_2000 INTERVAL DAY(3) TO SECOND;&lt;br /&gt;BEGIN &lt;br /&gt;   days_in_2000 := begin_2001 Ð begin_2000;&lt;br /&gt;&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;   x TIMESTAMP WITH TIME ZONE;&lt;br /&gt;   y INTERVAL YEAR TO MONTH;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;   x := TIMESTAMP '2002-07-14 21:15:00 -07:00';&lt;br /&gt;   y := INTERVAL '0-1' YEAR TO MONTH;&lt;br /&gt;   x := x + y;&lt;br /&gt;   x := x + INTERVAL '1 00:00:00' DAY TO SECOND;&lt;br /&gt;   DBMS_OUTPUT.PUT_LINE(TO_CHAR(&lt;br /&gt;      x, 'yyyy-mm-dd hh24:mi:ss tzh:tzm'));&lt;br /&gt;END;&lt;br /&gt;/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113865470638324263?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113865470638324263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113865470638324263' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113865470638324263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113865470638324263'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-plsql-interval-datatype.html' title='Oracle: PL/SQL interval datatype'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113843204397131204</id><published>2006-01-27T23:07:00.000-08:00</published><updated>2006-01-27T23:07:23.986-08:00</updated><title type='text'>Oracle: Locking</title><content type='html'>---------------- showsql.sql --------------------------&lt;br /&gt;column status format a10&lt;br /&gt;set feedback off&lt;br /&gt;set serveroutput on&lt;br /&gt;&lt;br /&gt;select username, sid, serial#, process, status&lt;br /&gt;from v$session&lt;br /&gt;where username is not null&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;column username format a20&lt;br /&gt;column sql_text format a55 word_wrapped&lt;br /&gt;&lt;br /&gt;set serveroutput on size 1000000&lt;br /&gt;declare&lt;br /&gt;    x number;&lt;br /&gt;begin&lt;br /&gt;    for x in&lt;br /&gt;    ( select username||'('||sid||','||serial#||&lt;br /&gt;                ') ospid = ' ||  process ||&lt;br /&gt;                ' program = ' || program username,&lt;br /&gt;             to_char(LOGON_TIME,' Day HH24:MI') logon_time,&lt;br /&gt;             to_char(sysdate,' Day HH24:MI') current_time,&lt;br /&gt;             sql_address, LAST_CALL_ET&lt;br /&gt;        from v$session&lt;br /&gt;       where status = 'ACTIVE'&lt;br /&gt;         and rawtohex(sql_address) &lt;&gt; '00'&lt;br /&gt;         and username is not null order by last_call_et )&lt;br /&gt;    loop&lt;br /&gt;        for y in ( select max(decode(piece,0,sql_text,null)) ||&lt;br /&gt;                          max(decode(piece,1,sql_text,null)) ||&lt;br /&gt;                          max(decode(piece,2,sql_text,null)) ||&lt;br /&gt;                          max(decode(piece,3,sql_text,null))&lt;br /&gt;                               sql_text&lt;br /&gt;                     from v$sqltext_with_newlines&lt;br /&gt;                    where address = x.sql_address&lt;br /&gt;                      and piece &lt; 4)&lt;br /&gt;        loop&lt;br /&gt;            if ( y.sql_text not like '%listener.get_cmd%' and&lt;br /&gt;                 y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%')&lt;br /&gt;            then&lt;br /&gt;                dbms_output.put_line( '--------------------' );&lt;br /&gt;                dbms_output.put_line( x.username );&lt;br /&gt;                dbms_output.put_line( x.logon_time || ' ' ||&lt;br /&gt;                                      x.current_time||&lt;br /&gt;                                      ' last et = ' ||&lt;br /&gt;                                      x.LAST_CALL_ET);&lt;br /&gt;                dbms_output.put_line(&lt;br /&gt;                          substr( y.sql_text, 1, 250 ) );&lt;br /&gt;            end if;&lt;br /&gt;        end loop;&lt;br /&gt;    end loop;&lt;br /&gt;end;&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;column username format a15 word_wrapped&lt;br /&gt;column module format a15 word_wrapped&lt;br /&gt;column action format a15 word_wrapped&lt;br /&gt;column client_info format a30 word_wrapped&lt;br /&gt;&lt;br /&gt;select username||'('||sid||','||serial#||')' username,&lt;br /&gt;       module,&lt;br /&gt;       action,&lt;br /&gt;       client_info&lt;br /&gt;from v$session&lt;br /&gt;where module||action||client_info is not null;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113843204397131204?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113843204397131204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113843204397131204' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113843204397131204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113843204397131204'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-locking.html' title='Oracle: Locking'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113840953852573483</id><published>2006-01-27T16:49:00.000-08:00</published><updated>2006-01-27T16:52:18.566-08:00</updated><title type='text'>Shell: Korn: rename file in subdirectory</title><content type='html'># rename directory first&lt;br /&gt;&lt;br /&gt;for f in `find . -type d`; do&lt;br /&gt;g=`echo $f | tr '[A-Z]' '[a-z]'`&lt;br /&gt;mv "$f" "$g"&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;# then rename all files in subdirectory&lt;br /&gt;for f in `find . ! -type d`; do&lt;br /&gt;g=`echo $f | tr '[A-Z]' '[a-z]'`&lt;br /&gt;mv "$f" "$g"&lt;br /&gt;done&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113840953852573483?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113840953852573483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113840953852573483' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113840953852573483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113840953852573483'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/shell-korn-rename-file-in-subdirectory.html' title='Shell: Korn: rename file in subdirectory'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113832137522270209</id><published>2006-01-26T16:14:00.000-08:00</published><updated>2006-01-26T16:22:55.236-08:00</updated><title type='text'>Oracle: Fine-grained audit</title><content type='html'>http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/nanda_fga.html&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;  dbms_fga.add_policy (&lt;br /&gt;    object_schema=&gt;'BANK',&lt;br /&gt;    object_name=&gt;'ACCOUNTS',&lt;br /&gt;    policy_name=&gt;'ACCOUNTS_ACCESS'&lt;br /&gt;  );&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;select timestamp, db_user, os_user, object_schema, sql_text&lt;br /&gt;from dba_fga_audit_trail;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;   dbms_fga.add_policy (&lt;br /&gt;      object_schema=&gt;'BANK',&lt;br /&gt;      object_name=&gt;'ACCOUNTS',&lt;br /&gt;      policy_name=&gt;'ACCOUNTS_ACCESS',&lt;br /&gt;      audit_column =&gt; 'BALANCE',&lt;br /&gt;      audit_condition =&gt; 'BALANCE &gt;= 11000'&lt;br /&gt;  );&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;FGA requires cost-based optimization(CBO) in order to work correctly&lt;br /&gt;&lt;br /&gt;begin &lt;br /&gt;   dbms_fga.drop_policy (&lt;br /&gt;      object_schema =&gt; 'BANK',&lt;br /&gt;      object_name =&gt; 'ACCOUNTS',&lt;br /&gt;      policy_name =&gt; 'ACCOUNTS_ACCESS'&lt;br /&gt;   );&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;begin &lt;br /&gt;   dbms_fga.enable_policy (&lt;br /&gt;      object_schema =&gt; 'BANK',&lt;br /&gt;      object_name =&gt; 'ACCOUNTS',&lt;br /&gt;      policy_name =&gt; 'ACCOUNTS_ACCESS',&lt;br /&gt;      enable =&gt; FALSE&lt;br /&gt;   );&lt;br /&gt;end;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113832137522270209?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113832137522270209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113832137522270209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113832137522270209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113832137522270209'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-fine-grained-audit.html' title='Oracle: Fine-grained audit'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113815639216142499</id><published>2006-01-24T18:17:00.000-08:00</published><updated>2006-01-24T18:33:12.176-08:00</updated><title type='text'>Oracle: Wait Events</title><content type='html'>1. DB File Scattered Read&lt;br /&gt; - This generally indicates waits related to full table scans. As full table scans&lt;br /&gt;   are pulled into memory, they rarely fll into contiguous buffers but instead are&lt;br /&gt;   scattered throughout the buffer cache. &lt;br /&gt; - A large number here indicates that your table may have missing or suppressed index&lt;br /&gt;   check to ensure that full table scan are necessary when you see these waits.&lt;br /&gt;   try to cache small tables to avoid reading them in over and over again, since&lt;br /&gt;   full table scan is put at cold end of LRU list.&lt;br /&gt;&lt;br /&gt;2. DB File Sequential Read&lt;br /&gt; - This event generally indicates a single block read(an index read, for example).&lt;br /&gt;   A large number of waits here could indicate poor joining orders of tables or &lt;br /&gt;   unselective indexing.&lt;br /&gt; - You should correlate this wait statistic with other known issues within the&lt;br /&gt;   statspack report, such as inefficient SQL. check to ensure that index scans are&lt;br /&gt;   necessary and join orders for multiple table joins.&lt;br /&gt;&lt;br /&gt;3. Free Buffer&lt;br /&gt; - This indicates your system is waiting for a buffer in memory because none is&lt;br /&gt;   available. Waits in this category may indicate that you need to increase the &lt;br /&gt;   DB_BUFFER_CACHE. It could also indicate that unselective SQL is causing data &lt;br /&gt;   to flood the buffer cache with index blocks.&lt;br /&gt; - This normally indicate that there's a substantial amount of DML being done and &lt;br /&gt;   that the DBWR is not writing quickly enough.&lt;br /&gt;   To address this, you may want to consider accelerating incremental checkpointing&lt;br /&gt;   using more DBWR processes or increasing the number of physical disks.&lt;br /&gt;&lt;br /&gt;4. Buffer Busy&lt;br /&gt;&lt;br /&gt;5. Latch Free&lt;br /&gt;&lt;br /&gt;6. Enqueue&lt;br /&gt; - An enqueue is a lock that protects a shared resource.&lt;br /&gt;&lt;br /&gt;7. Log Buffer space&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113815639216142499?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113815639216142499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113815639216142499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113815639216142499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113815639216142499'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-wait-events.html' title='Oracle: Wait Events'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113814587424100265</id><published>2006-01-24T15:32:00.000-08:00</published><updated>2006-01-24T15:37:54.253-08:00</updated><title type='text'>Oracle: Rman: Duplicate database on remote site</title><content type='html'>1) create a password file for duplicate instance(since you will connect as sysdba)&lt;br /&gt;orapwd file=/u01/app/oracle/product/9.2.0.1.0/dbs/orapwDUP password=password entries=10&lt;br /&gt;&lt;br /&gt;2) edit listener.ora and tnsnames.ora to make sure dup instance can be accessed from network.&lt;br /&gt;&lt;br /&gt;3) create pfile with minimum requirement.&lt;br /&gt;# Minimum Requirement.&lt;br /&gt;DB_NAME=DUP&lt;br /&gt;CONTROL_FILES=(/u02/oradata/DUP/control01.ctl,&lt;br /&gt;               /u02/oradata/DUP/control02.ctl,&lt;br /&gt;               /u02/oradata/DUP/control03.ctl)&lt;br /&gt;&lt;br /&gt;# Convert file names to allow for different directory structure.&lt;br /&gt;DB_FILE_NAME_CONVERT=(/u02/oradata/TSH1/,/u02/oradata/DUP/)&lt;br /&gt;LOG_FILE_NAME_CONVERT=(/u01/oradata/TSH1/,/u01/oradata/DUP/)&lt;br /&gt;&lt;br /&gt;# make sure block_size and compatible parameters&lt;br /&gt;# match if you are not using the default.&lt;br /&gt;DB_BLOCK_SIZE=8192&lt;br /&gt;COMPATIBLE=9.2.0.0.0&lt;br /&gt;&lt;br /&gt;4) create spfile from pfile and start instance &lt;br /&gt;sqlplus /nolog&lt;br /&gt;conn / as sysdba&lt;br /&gt;CREATE SPFILE FROM PFILE='/u01/app/oracle/admin/DUP/pfile/init.ora';&lt;br /&gt;STARTUP FORCE NOMOUNT;&lt;br /&gt;&lt;br /&gt;5) Backup original database&lt;br /&gt;rman target / catalog rman/cat@oem&lt;br /&gt;rman&gt; backup database&lt;br /&gt;rman&gt; backup archivelog all delete input&lt;br /&gt;&lt;br /&gt;6) duplicate database&lt;br /&gt;man TARGET sys/password@tsh1 CATALOG rman/rman@tshadm AUXILIARY /&lt;br /&gt;DUPLICATE TARGET DATABASE TO DUP;&lt;br /&gt;or&lt;br /&gt;# Duplicate database to TARGET's state 4 days ago.&lt;br /&gt;DUPLICATE TARGET DATABASE TO DUP UNTIL TIME 'SYSDATE-4'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113814587424100265?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113814587424100265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113814587424100265' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113814587424100265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113814587424100265'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-rman-duplicate-database-on.html' title='Oracle: Rman: Duplicate database on remote site'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113788379582903485</id><published>2006-01-21T14:49:00.000-08:00</published><updated>2006-01-21T14:49:55.846-08:00</updated><title type='text'>Oracle: Data Guard</title><content type='html'>http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96653/standbycon.htm&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113788379582903485?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113788379582903485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113788379582903485' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113788379582903485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113788379582903485'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-data-guard.html' title='Oracle: Data Guard'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113780000771799264</id><published>2006-01-20T15:29:00.000-08:00</published><updated>2006-01-20T15:33:27.733-08:00</updated><title type='text'>Oracle: create package</title><content type='html'>CREATE or REPLACE PACKAGE test_actions AS&lt;br /&gt;  PROCEDURE add_entry(c1 number, c2 varchar2);&lt;br /&gt;  PROCEDURE del_entry(c1 number);&lt;br /&gt;END test_actions;&lt;br /&gt;&lt;br /&gt;CREATE or REPLACE PACKAGE BODY test_actions AS&lt;br /&gt;  PROCEDURE add_entry(c1 number, c2 varchar2);&lt;br /&gt;  BEGIN&lt;br /&gt;     INSERT INTO test2(c1,c2) VALUES(c1,c2);&lt;br /&gt;  END add_entry;&lt;br /&gt;  PROCEDURE del_entry(c1 number)&lt;br /&gt;  BEGIN&lt;br /&gt;     DELETE FROM test2 WHERE c1 = c1;&lt;br /&gt;  END del_entry;&lt;br /&gt;END test_actions;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113780000771799264?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113780000771799264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113780000771799264' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113780000771799264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113780000771799264'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-create-package.html' title='Oracle: create package'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113728224794798172</id><published>2006-01-14T15:40:00.000-08:00</published><updated>2006-01-14T15:45:07.300-08:00</updated><title type='text'>Oracle: bind variables and ksh</title><content type='html'>#!/bin/ksh&lt;br /&gt;&lt;br /&gt;function f&lt;br /&gt;{&lt;br /&gt;sqlplus -s &lt;&lt;eof&gt; login/passwd@db&lt;br /&gt;var v1 varchar2(10);&lt;br /&gt;var v2 varchar2(10);&lt;br /&gt;exec :v1 := '$1';&lt;br /&gt;exec :v2 := '$2';&lt;br /&gt;exec pkg.prc(:v1, :v2);&lt;br /&gt;EOF&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;f A B&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113728224794798172?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113728224794798172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113728224794798172' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113728224794798172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113728224794798172'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-bind-variables-and-ksh.html' title='Oracle: bind variables and ksh'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113709454556972718</id><published>2006-01-12T11:35:00.000-08:00</published><updated>2006-01-12T11:35:45.586-08:00</updated><title type='text'>Unix: Search text in subdirectories</title><content type='html'>find . -print -name *.sh |xargs grep ECProductUpdate&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113709454556972718?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113709454556972718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113709454556972718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113709454556972718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113709454556972718'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/unix-search-text-in-subdirectories.html' title='Unix: Search text in subdirectories'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113659636256508369</id><published>2006-01-06T14:27:00.000-08:00</published><updated>2006-01-06T17:12:42.916-08:00</updated><title type='text'>Oracle: perf views</title><content type='html'>1. v$session_wait : current state view. It lists either the event currently &lt;br /&gt;   being waited for or the event last waited for on each session&lt;br /&gt;&lt;br /&gt;2. v$session_event: lists the cumulative history of events waited for on each&lt;br /&gt;   session. After a session exits, the wait event statistics for that session are&lt;br /&gt;   removed from this view.&lt;br /&gt;&lt;br /&gt;3. v$system_event: lists the events and times waited for by the whole instance&lt;br /&gt;   (that is, all session wait events data rolled up) since instance startup. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;v$session_wait is current state view. it also contains a finer-granularity of&lt;br /&gt; information than v$session_event or v$system_event.&lt;br /&gt; it includes additional identifying data for the current event in three parameter&lt;br /&gt; columns: P1, P2 and P3.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113659636256508369?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113659636256508369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113659636256508369' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113659636256508369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113659636256508369'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2006/01/oracle-perf-views.html' title='Oracle: perf views'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113592116102953960</id><published>2005-12-29T21:33:00.000-08:00</published><updated>2005-12-29T22:01:29.366-08:00</updated><title type='text'>Unix: Rsync password authentication</title><content type='html'>1) create configre file /usr/local/etc/rsyncd.conf&lt;br /&gt;chmod 640 rsyncd.conf&lt;br /&gt;&lt;br /&gt;uid             = rsync&lt;br /&gt;gid             = rsync&lt;br /&gt;use chroot      = no&lt;br /&gt;max connections = 4&lt;br /&gt;syslog facility = local5&lt;br /&gt;pid file        = /var/run/rsyncd.pid&lt;br /&gt;&lt;br /&gt;[www]&lt;br /&gt;        path    = /usr/local/websites/&lt;br /&gt;        comment = all of the websites&lt;br /&gt;&lt;br /&gt;2) create user/group as rsync/rsync&lt;br /&gt;&lt;br /&gt;3) run rsyncd as "rsync --daemon"&lt;br /&gt;&lt;br /&gt;4) create /usr/local/etc/rsyncd.conf (use mode 640)&lt;br /&gt;auth users = tridge, susan&lt;br /&gt;secrets file = /usr/local/etc/rsyncd.secrets&lt;br /&gt;&lt;br /&gt;5) create /usr/local/etc/rsyncd.secrets  (chmod 640)&lt;br /&gt;tridge:mypass&lt;br /&gt;susan:herpass&lt;br /&gt;&lt;br /&gt;6) rsync -avz susan@ducky::www /home/dan/test&lt;br /&gt;&lt;br /&gt;7) add option "--password-file /home/dan/test/rsync.password"&lt;br /&gt;add password in /home/dan/test/rsync.password&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113592116102953960?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113592116102953960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113592116102953960' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113592116102953960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113592116102953960'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/unix-rsync-password-authentication.html' title='Unix: Rsync password authentication'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113590252866795498</id><published>2005-12-29T16:27:00.000-08:00</published><updated>2005-12-29T16:28:48.683-08:00</updated><title type='text'>UNIX: context switch</title><content type='html'>Each process has its own virtual memory space. References to real memory are provided through a process-specific set of address translation maps. The computer's Memory Management Unit (MMU) contains a set of registers that point to the current process's address translation maps. When the current process changes, the MMU must load the translation maps for the new process. This is called a "Context Switch"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113590252866795498?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113590252866795498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113590252866795498' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113590252866795498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113590252866795498'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/unix-context-switch.html' title='UNIX: context switch'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113573530458565549</id><published>2005-12-27T17:18:00.000-08:00</published><updated>2005-12-27T18:01:44.600-08:00</updated><title type='text'>Oracle: transformation between v$lock and v$session_wait</title><content type='html'>enqueue&lt;br /&gt;  -- P1: lock type(or name) and mode&lt;br /&gt;  -- P2: resource identifier ID1 for the lock&lt;br /&gt;  -- P3: resource identifier ID2 for the lock&lt;br /&gt;&lt;br /&gt;v$lock.id1 = p2&lt;br /&gt;v$lock.id2 = p3&lt;br /&gt;&lt;br /&gt;--lock type:&lt;br /&gt;  v$lock.type = chr(bitand(p1,-16777216)/16777215)||chr(bitand(p1,1671680)/65535)&lt;br /&gt;&lt;br /&gt;--the mode in which the enqueue is being requested&lt;br /&gt;  v$lock.request = mod(p1,65536)&lt;br /&gt;&lt;br /&gt;--find locks and lock holders&lt;br /&gt;to show only holders and waiters for locks being waited on&lt;br /&gt;select decode(request,0,'Holder: ','Waiter: ')||sid sess,&lt;br /&gt;       id1,&lt;br /&gt;       id2,&lt;br /&gt;       lmode,&lt;br /&gt;       request,&lt;br /&gt;       type&lt;br /&gt;from v$lock&lt;br /&gt;where (id1, id2, type) in &lt;br /&gt;      (select id1, id2, type from v$lock where request &gt; 0)&lt;br /&gt;order by id1, request;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113573530458565549?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113573530458565549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113573530458565549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113573530458565549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113573530458565549'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-transformation-between-vlock.html' title='Oracle: transformation between v$lock and v$session_wait'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113573194173761284</id><published>2005-12-27T17:04:00.000-08:00</published><updated>2005-12-27T17:10:29.580-08:00</updated><title type='text'>Oracle: i/o wait events</title><content type='html'>1) db file sequential read:&lt;br /&gt;  single block read into one SGA buffer&lt;br /&gt;  single block I/Os are usually the result of using indexes &lt;br /&gt;  rarely, full table scan calls could get truncated to a single block call due to&lt;br /&gt;  extent boundaries, or buffers already present into the buffer cache.&lt;br /&gt;&lt;br /&gt;2) db file scattered read:&lt;br /&gt;  multiblock read into many discontinuous SGA buffers&lt;br /&gt;  scattered read wait event identified that a full table scan is occurring.&lt;br /&gt;&lt;br /&gt;3) direct read:&lt;br /&gt;  single or multiblock read into the PGA, bypassing the SGA&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113573194173761284?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113573194173761284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113573194173761284' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113573194173761284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113573194173761284'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-io-wait-events.html' title='Oracle: i/o wait events'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113530331590047805</id><published>2005-12-22T17:52:00.000-08:00</published><updated>2005-12-22T18:01:55.913-08:00</updated><title type='text'>Oracle: Wait events</title><content type='html'>-- query following views for wait events&lt;br /&gt;V$SESSION_WAIT  V$SESSION_EVENT  V$SYSTEM_EVENT&lt;br /&gt;&lt;br /&gt; -- V$SESSION_WAIT is a current state view.&lt;br /&gt;    it lists either the event currently being waited for or the event last waited&lt;br /&gt;    for on each session&lt;br /&gt; -- V$SESSION_EVENT lists the cumulative history of events waited for on each session&lt;br /&gt;    After a session exists, the wait event statics for that session are removed from &lt;br /&gt;    this view.&lt;br /&gt; -- V$SYSTEM_EVENT lists the events and times waited for by the whole instance&lt;br /&gt;    since instance startup&lt;br /&gt;&lt;br /&gt;-- timed statistics are automatically collected for database&lt;br /&gt;if the initialization parameter statistics_level is set to typical or all&lt;br /&gt;if STATISTICS is set to BASIC, then you must set TIMED_STATISTICS to TRUE to enable&lt;br /&gt;collection of timed statistics&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113530331590047805?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113530331590047805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113530331590047805' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113530331590047805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113530331590047805'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-wait-events.html' title='Oracle: Wait events'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113521459079343961</id><published>2005-12-21T17:19:00.000-08:00</published><updated>2005-12-21T17:23:10.803-08:00</updated><title type='text'>Linux: Tune disk device</title><content type='html'>-query current device settings&lt;br /&gt;/sbin/hdparm /dev/hda&lt;br /&gt;&lt;br /&gt;-run benchmark before tuning&lt;br /&gt;/dbin/hdparm -Tt /dev/hda&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113521459079343961?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113521459079343961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113521459079343961' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113521459079343961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113521459079343961'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/linux-tune-disk-device.html' title='Linux: Tune disk device'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113520682607956327</id><published>2005-12-21T15:13:00.000-08:00</published><updated>2005-12-21T15:13:46.093-08:00</updated><title type='text'>Sybase: SQL text auditing</title><content type='html'>exec sp_audit cmdtext,wlsuser,"all","on"&lt;br /&gt;exec sp_audit cmdtext,wlsuser,"all","off"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113520682607956327?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113520682607956327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113520682607956327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113520682607956327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113520682607956327'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/sybase-sql-text-auditing.html' title='Sybase: SQL text auditing'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113513031352461886</id><published>2005-12-20T17:53:00.000-08:00</published><updated>2005-12-20T17:58:33.543-08:00</updated><title type='text'>Solaris: How to limit display of other user's processes</title><content type='html'>On Solaris10, it is possible to allow user only see their own processes by command&lt;br /&gt;ps -aef&lt;br /&gt;&lt;br /&gt;Following is how to configure it.&lt;br /&gt;1)to set limit globally edit /etc/security/policy.conf file and uncomment PRIV_DEFAULT line&lt;br /&gt;set its value as&lt;br /&gt;PRIV_DEFAULT=basic,!proc_info&lt;br /&gt;&lt;br /&gt;2)to set limit per user basis&lt;br /&gt;edit /etc/user_attr and add following entry&lt;br /&gt;gmb::::lock_after_retries=no;defaultpriv=basic&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113513031352461886?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113513031352461886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113513031352461886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113513031352461886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113513031352461886'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/solaris-how-to-limit-display-of-other.html' title='Solaris: How to limit display of other user&apos;s processes'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113512223858163013</id><published>2005-12-20T15:42:00.000-08:00</published><updated>2005-12-20T15:43:58.600-08:00</updated><title type='text'>Oracle: PL/SQL table and cursor</title><content type='html'>set serveroutput on&lt;br /&gt;&lt;br /&gt;declare&lt;br /&gt;  -- Declare the PL/SQL table&lt;br /&gt;  type deptarr is table of dept%rowtype&lt;br /&gt;       index by binary_integer;&lt;br /&gt;  d_arr deptarr;&lt;br /&gt;&lt;br /&gt;  -- Declare cursor&lt;br /&gt;  type d_cur is ref cursor return dept%rowtype;&lt;br /&gt;  c1 d_cur;&lt;br /&gt;&lt;br /&gt;  i number := 1;&lt;br /&gt;begin&lt;br /&gt;  -- Populate the PL/SQL table from the cursor&lt;br /&gt;  open c1 for select * from dept;&lt;br /&gt;  loop&lt;br /&gt;    exit when c1%NOTFOUND;&lt;br /&gt;    fetch c1 into d_arr(i);&lt;br /&gt;    i := i+1;&lt;br /&gt;  end loop;&lt;br /&gt;  close c1;&lt;br /&gt;&lt;br /&gt;  -- Display the entire PL/SQL table on screen&lt;br /&gt;  for i in 1..d_arr.last loop&lt;br /&gt;    dbms_output.put_line('DEPTNO : '||d_arr(i).deptno );&lt;br /&gt;    dbms_output.put_line('DNAME  : '||d_arr(i).dname  );&lt;br /&gt;    dbms_output.put_line('LOC    : '||d_arr(i).loc    );&lt;br /&gt;    dbms_output.put_line('---------------------------');&lt;br /&gt;  end loop;&lt;br /&gt;end;&lt;br /&gt;/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113512223858163013?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113512223858163013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113512223858163013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113512223858163013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113512223858163013'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-plsql-table-and-cursor.html' title='Oracle: PL/SQL table and cursor'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113502992402168459</id><published>2005-12-19T13:58:00.000-08:00</published><updated>2005-12-19T14:05:24.033-08:00</updated><title type='text'>Oracle: 9i flashback query</title><content type='html'>Flashback Query is enabled and disabled using the DBMS_FLASHBACK package. The point in time of the flashback can be specified using the SCN or the actual time:&lt;br /&gt;&lt;br /&gt;    EXECUTE Dbms_Flashback.Enable_At_System_Change_Number(123);&lt;br /&gt;    EXECUTE Dbms_Flashback.Enable_At_Time('28-AUG-01 11:00:00');&lt;br /&gt;&lt;br /&gt;Once you've finished performing all your read-only operations you can turn off flashback query using:&lt;br /&gt;&lt;br /&gt;    EXECUTE Dbms_Flashback.Disable;&lt;br /&gt;&lt;br /&gt;to get current system change number&lt;br /&gt;   &lt;br /&gt;    select dbms_flashback.get_system_change_number from dual;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113502992402168459?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113502992402168459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113502992402168459' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113502992402168459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113502992402168459'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-9i-flashback-query.html' title='Oracle: 9i flashback query'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113450135820500297</id><published>2005-12-13T11:10:00.000-08:00</published><updated>2005-12-13T11:15:58.216-08:00</updated><title type='text'>Rsync: certification authentication on unix</title><content type='html'>1) use rsync over ssh to copy files between systems&lt;br /&gt;   rsync -av -e ssh src:/dir/* dest:/dir&lt;br /&gt;&lt;br /&gt;2) use rsync over ssh and use public key for user authentication&lt;br /&gt;   (login from host A to host B without password authentication)&lt;br /&gt;   1) on host A generate private/public key pair&lt;br /&gt;      ssh-keygen -t rsa -b 2048 -f ~/.ssh_key/A-rsync-key&lt;br /&gt;   2) copy A-rsync-key.pub file to host B:~/.ssh/authorized_keys file&lt;br /&gt;      (use sshd_config to determine the location of this file)&lt;br /&gt;   3) create "config" file in A:~/.ssh as&lt;br /&gt;      Host B&lt;br /&gt;      User root&lt;br /&gt;      Compression yes&lt;br /&gt;      Protocol 2&lt;br /&gt;      RSAAuthentication yes&lt;br /&gt;      StrictHostKeyChecking no&lt;br /&gt;      ForwardAgent yes&lt;br /&gt;      ForwardX11 no&lt;br /&gt;      IdentityFile /.ssh_key/A-rsync-key&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113450135820500297?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113450135820500297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113450135820500297' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113450135820500297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113450135820500297'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/rsync-certification-authentication-on.html' title='Rsync: certification authentication on unix'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113450035862946399</id><published>2005-12-13T10:55:00.000-08:00</published><updated>2005-12-13T10:59:18.646-08:00</updated><title type='text'>Apache: configure SSI - server side includes</title><content type='html'>1) add following lines to httpd.conf&lt;br /&gt;AddType text/html .shtml &lt;br /&gt;AddHandler server-parsed .shtml &lt;br /&gt;&lt;br /&gt;2) modify options line in Document root to add Includes&lt;br /&gt;Options Indexes FollowSymLinks +Includes &lt;br /&gt;&lt;br /&gt;3) optionally turn on XBitHack&lt;br /&gt;XBitHack On&lt;br /&gt;and chmod 744 filename&lt;br /&gt;&lt;br /&gt;4) alternatively you can create .htaccess file under a given directory and add&lt;br /&gt;AddType text/html .shtml&lt;br /&gt;AddHandler server-parsed .shtml&lt;br /&gt;Options Indexes FollowSymLinks Includes&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113450035862946399?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113450035862946399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113450035862946399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113450035862946399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113450035862946399'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/apache-configure-ssi-server-side.html' title='Apache: configure SSI - server side includes'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113418828221718383</id><published>2005-12-09T20:16:00.000-08:00</published><updated>2005-12-09T20:18:02.230-08:00</updated><title type='text'>Perl: Serach Matching</title><content type='html'>.*  :  match anything not a newline till end of line&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113418828221718383?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113418828221718383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113418828221718383' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113418828221718383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113418828221718383'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/perl-serach-matching.html' title='Perl: Serach Matching'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113398414940282069</id><published>2005-12-07T11:33:00.000-08:00</published><updated>2006-01-26T18:26:09.016-08:00</updated><title type='text'>Oracle: trace event</title><content type='html'>init.ora: event='1401 trace name errorstack, level 12'&lt;br /&gt;&lt;br /&gt;user session: alter session set events '10046 trace name context forever, level 4';&lt;br /&gt;&lt;br /&gt;    * 10046 trace name context forever, level 4&lt;br /&gt;&lt;br /&gt;      Trace SQL statements and show bind variables in trace output.&lt;br /&gt;&lt;br /&gt;    * 10046 trace name context forever, level 8&lt;br /&gt;&lt;br /&gt;      This shows wait events in the SQL trace files&lt;br /&gt;&lt;br /&gt;    * 10046 trace name context forever, level 12&lt;br /&gt;&lt;br /&gt;      This shows both bind variable names and wait events in the SQL trace files&lt;br /&gt;&lt;br /&gt;    * 1401 trace name errorstack, level 12&lt;br /&gt;      1401 trace name errorstack, level 4&lt;br /&gt;      1401 trace name processstate&lt;br /&gt;&lt;br /&gt;      Dumps out trace information if an ORA-1401 "inserted value too large for column" error&lt;br /&gt;      occurs. The 1401 can be replaced by any other Oracle Server error code that you want &lt;br /&gt;      to trace.&lt;br /&gt;&lt;br /&gt;    * 60 trace name errorstack level 10&lt;br /&gt;&lt;br /&gt;      Show where in the code Oracle gets a deadlock (ORA-60), and may help to diagnose &lt;br /&gt;      the problem.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;============================================================&lt;br /&gt;SQL&gt; oradebug setmypid &lt;br /&gt;SQL&gt; oradebug unlimit&lt;br /&gt;SQL&gt; oradebug dump systemstate 10 &lt;br /&gt;SQL&gt; oradebug tracefile_name&lt;br /&gt;or to trace a specific error &lt;br /&gt;SQL&gt; select username, spid from v$process;&lt;br /&gt;SQL&gt; oradebug setospid 2280&lt;br /&gt;SQL&gt; oradebug event 10046 trace name context off&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113398414940282069?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113398414940282069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113398414940282069' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113398414940282069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113398414940282069'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-trace-event.html' title='Oracle: trace event'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113398329657035837</id><published>2005-12-07T11:21:00.000-08:00</published><updated>2005-12-07T11:27:29.926-08:00</updated><title type='text'>Oracle: lock - enqueue</title><content type='html'>A latch is an internal Oracle mechanism used to protect data structures in the SGA from simultaneous access. Atomic hardware instructions like TEST-AND-SET are used to implement latches. Latches are more restrictive than locks in that they are always exclusive. Latches are never queued, but will spin or sleep until they obtain a resource, or time out.&lt;br /&gt;&lt;br /&gt;Enqueues and locks are different names for the same thing. Both support queuing and concurrency. They are queued and serviced in a first-in-first-out (FIFO) order.&lt;br /&gt;&lt;br /&gt;Semaphores are an operating system facility used to control waiting. Semaphores are controlled by the following Unix parameters: semmni, semmns and semmsl. Typical settings are:&lt;br /&gt;&lt;br /&gt;        semmns = sum of the "processes" parameter for each instance&lt;br /&gt;               (see init&lt;instance&gt;.ora for each instance)&lt;br /&gt;        semmni = number of instances running simultaneously;&lt;br /&gt;        semmsl = semmns&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113398329657035837?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113398329657035837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113398329657035837' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113398329657035837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113398329657035837'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-lock-enqueue.html' title='Oracle: lock - enqueue'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113391846656613835</id><published>2005-12-06T17:19:00.000-08:00</published><updated>2005-12-06T17:21:06.583-08:00</updated><title type='text'>Oracle: v$sql_plan view</title><content type='html'>SQL Execution Statistics in 9i &lt;br /&gt;&lt;br /&gt;The SQL tuning process prior to 9.2 involved executing SQL commands, then OS commands, and then SQL commands again. This is a very time-consuming and burdensome process. In 9.2, Oracle decided to retain the SQL metrics for each statement in the SGA (library cache) while the statement remains cached. The DBA could then diagnose SQL issues at a SQL prompt and leave tkprof alone. This is a vast improvement over prior versions. &lt;br /&gt;&lt;br /&gt;Oracle9.2 contains the following views that enable the DBA to identify SQL issues directly from a SQL prompt. These views should be used to periodically check SQL statistics and full-table scans, alerting the DBA to problem areas requiring corrective action.&lt;br /&gt;&lt;br /&gt;• v$sql_plan - This view shows the same information as shown by Explain Plan except it is the actual execution plan and not the predicted one – just like tkprof and even better than Explain Plan. &lt;br /&gt;&lt;br /&gt;• v$sql_plan_statistics - This view contains the execution statistics for each operation (step) in the v$sql_plan. Queries should access this view and look for poor SQL operations including TABLE ACCESS FULL – full-table scans.&lt;br /&gt;&lt;br /&gt;• v$sql_plan_statistics_all - This view combines data from v$sql_plan, v$sql_plan_statistics and v$sql_workarea. &lt;br /&gt;&lt;br /&gt;Both v$sql_plan_statistics and v$sql_plan_statistics_all are not populated by default. The option statistics_level=all must be set.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to query v$sql_plan&lt;br /&gt;1) retrieve "address" and "hash_value" from v$sql&lt;br /&gt;2) query v$sql_plan with columns "operation","options","object_name" and "cost"&lt;br /&gt;   using "address" and "hash_value" as primary key.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113391846656613835?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113391846656613835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113391846656613835' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113391846656613835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113391846656613835'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/oracle-vsqlplan-view.html' title='Oracle: v$sql_plan view'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113376136168615508</id><published>2005-12-04T21:39:00.000-08:00</published><updated>2005-12-04T21:42:41.696-08:00</updated><title type='text'>Perl: Find the Nth Occurrence of a match</title><content type='html'>while(/(\w+)\s+fish\b/gi){&lt;br /&gt;  if(++$count == $WANT){&lt;br /&gt;      # do what ever you want to do&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;\w+ match a word&lt;br /&gt;\s+ 1 or n space&lt;br /&gt;\b  word boundary&lt;br /&gt;/g  gloal match/substitue as often as possible.&lt;br /&gt;/i  ignore case&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113376136168615508?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113376136168615508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113376136168615508' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113376136168615508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113376136168615508'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/perl-find-nth-occurrence-of-match.html' title='Perl: Find the Nth Occurrence of a match'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113374481267957538</id><published>2005-12-04T17:05:00.000-08:00</published><updated>2005-12-04T17:06:52.680-08:00</updated><title type='text'>Perl: match numbers</title><content type='html'>to match one or more numbers in a string&lt;br /&gt;&lt;br /&gt;$str ~= /(\d+)/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113374481267957538?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113374481267957538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113374481267957538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113374481267957538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113374481267957538'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/perl-match-numbers.html' title='Perl: match numbers'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113374413726135879</id><published>2005-12-04T16:52:00.000-08:00</published><updated>2005-12-04T16:55:37.276-08:00</updated><title type='text'>Perl: difference between + and *</title><content type='html'>+ means 1 or more occurences&lt;br /&gt;&lt;br /&gt;* means 0 or more occurences&lt;br /&gt;&lt;br /&gt;for examples:&lt;br /&gt;&lt;br /&gt;$str = "good food";&lt;br /&gt;($str1 = $str) =~ s/o*/e;&lt;br /&gt;($str2 = $str) =~ s/o+/e;&lt;br /&gt;&lt;br /&gt;result is:&lt;br /&gt;$str1: egood food&lt;br /&gt;$str2: ged food&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113374413726135879?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113374413726135879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113374413726135879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113374413726135879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113374413726135879'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/perl-difference-between-and.html' title='Perl: difference between + and *'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113355237826235556</id><published>2005-12-02T11:37:00.000-08:00</published><updated>2005-12-02T11:39:38.273-08:00</updated><title type='text'>Perl: transaction across databases</title><content type='html'>How to create transaction across multiple databases in perl script.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#!/usr/local/bin/perl -w&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# this script will test transaction rollback&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;use DBD::Sybase;&lt;br /&gt;&lt;br /&gt;$dbh_ora = DBI-&gt;connect("dbi:Oracle:host=192.168.69.11;sid=qadtrain",&lt;br /&gt;                        'qad',&lt;br /&gt;                        'qad',&lt;br /&gt;                        {AutoCommit=&gt;0}&lt;br /&gt;                        )|| die "Database connection not made: $DBI::errstr";&lt;br /&gt;&lt;br /&gt;$dbh_syb = DBI-&gt;connect("dbi:Sybase:server=DEVELOP;database=CIS",&lt;br /&gt;                        "sa",&lt;br /&gt;                        "october"&lt;br /&gt;                        )|| die "Database connection not made: $DBI::errstr";&lt;br /&gt;&lt;br /&gt;$dbh_syb-&gt;{AutoCommit}=0;&lt;br /&gt;$dbh_syb-&gt;{RaiseError}=1;&lt;br /&gt;&lt;br /&gt;$dbh_ora-&gt;{AutoCommit}=0;&lt;br /&gt;$dbh_syb-&gt;{RaiseError}=1;&lt;br /&gt;&lt;br /&gt;eval{&lt;br /&gt;        my $v1=4;&lt;br /&gt;        $sth_ora=$dbh_ora-&gt;prepare("insert into peij1 values(?,?)");&lt;br /&gt;        $sth_ora-&gt;execute($v1,$v1);&lt;br /&gt;        $sth_syb=$dbh_syb-&gt;prepare("insert into peij1 values(?,?)");&lt;br /&gt;        $sth_syb-&gt;execute($v1,$v1);&lt;br /&gt;        $dbh_ora-&gt;commit;&lt;br /&gt;        $dbh_syb-&gt;commit;&lt;br /&gt;};&lt;br /&gt;if($@){&lt;br /&gt;        warn "Transaction aborted due to $@";&lt;br /&gt;        $dbh_ora-&gt;rollback;&lt;br /&gt;        $dbh_syb-&gt;rollback;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113355237826235556?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113355237826235556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113355237826235556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113355237826235556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113355237826235556'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/12/perl-transaction-across-databases.html' title='Perl: transaction across databases'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113322184714639407</id><published>2005-11-28T15:44:00.000-08:00</published><updated>2005-11-28T15:52:06.683-08:00</updated><title type='text'>Quick Sort</title><content type='html'>&lt;ol&gt;&lt;li&gt;Pick an element, called a pivot, from the list. &lt;/li&gt;&lt;li&gt;Reorder the list so that all elements which are less than the pivot come before the pivot and so that all elements greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation&lt;/li&gt;&lt;li&gt;&lt;a title="Recursion" href="http://en.wikipedia.org/wiki/Recursion"&gt;Recursively&lt;/a&gt; sort the sub-list of lesser elements and the sub-list of greater elements. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Pseudo Code:&lt;br /&gt;function quicksort(q)&lt;br /&gt;var list less, pivotList, greater&lt;br /&gt;if length(q) = 1&lt;br /&gt;return q&lt;br /&gt;else&lt;br /&gt;select a pivot value pivot from q&lt;br /&gt;for each x in q except the pivot element&lt;br /&gt;if x &lt;&gt; &lt;p&gt;if x = pivot then add x to greater&lt;/p&gt;&lt;p&gt;add pivot to pivotList&lt;/p&gt;&lt;p&gt;return concatenate(quicksort(less), pivotList, quicksort(greater))&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;TYPE int_arr IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;&lt;br /&gt;&lt;br /&gt;procedure qsort(arr in out int_arr, lo in INTEGER, hi in INTEGER ) is&lt;br /&gt;i INTEGER := lo;&lt;br /&gt;j INTEGER := hi;&lt;br /&gt;x INTEGER := arr((lo+hi)/2);&lt;br /&gt;tmp INTEGER;&lt;br /&gt;begin&lt;br /&gt;LOOP&lt;br /&gt;WHILE (arr(i) &lt;&gt; x LOOP&lt;br /&gt;j := j - 1;&lt;br /&gt;END LOOP;&lt;br /&gt;IF i &lt;= j THEN tmp := arr(i); arr(i) := arr(j); arr(j) := tmp; i := i + 1; j := j - 1; END IF; EXIT WHEN i &gt; j;&lt;br /&gt;END LOOP;&lt;br /&gt;IF lo &lt;&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113322184714639407?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113322184714639407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113322184714639407' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113322184714639407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113322184714639407'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/quick-sort.html' title='Quick Sort'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113261903512930504</id><published>2005-11-21T16:14:00.000-08:00</published><updated>2005-11-21T16:23:55.140-08:00</updated><title type='text'>Oracle: Choosing Index Keys</title><content type='html'>Guidelines for choosing keys to index:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Consider indexing keys that are used frequently in WHERE clauses.&lt;/li&gt;&lt;li&gt;Frequently to join tables in SQL statements.&lt;/li&gt;&lt;li&gt;have high selectivity(percentage of rows in a table that have the same value for indexed key). Indexing low selectivity columns can be helpful if the data distribution is skewed so that one or two values occur much less often than other values.&lt;/li&gt;&lt;li&gt;Do not use b-tree indexes n keys with few distinct vlues.&lt;/li&gt;&lt;li&gt;Do not index columns that are modified frequently&lt;/li&gt;&lt;li&gt;Do not index keys that appear only in WHERE clauses with functions or operators except with function based  indexes.&lt;/li&gt;&lt;li&gt;Consider indexing foreign keys of referential intergrity constraints in cases in which a large number of I/U/D access the parent and child tables. this will avoid "share locking" on child table.&lt;/li&gt;&lt;li&gt;when choosing to index a key, you should balance the perf gain for queries and the perf loss for I/U/Ds by using SQL trace facility.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113261903512930504?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113261903512930504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113261903512930504' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113261903512930504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113261903512930504'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-choosing-index-keys.html' title='Oracle: Choosing Index Keys'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113245135151072716</id><published>2005-11-19T17:44:00.000-08:00</published><updated>2005-11-19T17:49:11.523-08:00</updated><title type='text'>Oracle: Flashback Query in 10g</title><content type='html'>select versions_starttime, versions_endtime, versions_xid,&lt;br /&gt;versions_operation, rate&lt;br /&gt;from rates versions between timestamp minvalue and maxvalue&lt;br /&gt;order by VERSIONS_STARTTIME&lt;br /&gt;&lt;br /&gt;select rate, versions_starttime, versions_endtime&lt;br /&gt;from rates versions&lt;br /&gt;between timestamp&lt;br /&gt;to_date('12/1/2003 15:57:54','mm/dd/yyyy hh24:mi:ss')&lt;br /&gt;and to_date('12/1/2003 16:57:55','mm/dd/yyyy hh24:mi:ss')&lt;br /&gt;&lt;br /&gt;select rate, versions_starttime, versions_endtime&lt;br /&gt;from rates versions&lt;br /&gt;between scn 1000 and 1001&lt;br /&gt;&lt;br /&gt; select versions_starttime, versions_endtime, versions_xid,&lt;br /&gt;versions_operation, rate&lt;br /&gt;from rates versions between timestamp&lt;br /&gt;to_date('12/11/2003 15:57:52', 'mm/dd/yyyy hh24:mi:ss')&lt;br /&gt;and maxvalue&lt;br /&gt;order by VERSIONS_STARTTIME&lt;br /&gt;&lt;br /&gt;SELECT UNDO_SQL&lt;br /&gt;FROM FLASHBACK_TRANSACTION_QUERY&lt;br /&gt;WHERE XID = '000A000D00000029';&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113245135151072716?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113245135151072716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113245135151072716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113245135151072716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113245135151072716'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-flashback-query-in-10g.html' title='Oracle: Flashback Query in 10g'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113202889210813620</id><published>2005-11-14T20:28:00.000-08:00</published><updated>2005-11-14T20:28:23.656-08:00</updated><title type='text'>Oracle: Links</title><content type='html'>&lt;a href="http://www.cuddletech.com/articles/oracle/node1.html"&gt;http://www.cuddletech.com/articles/oracle/node1.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113202889210813620?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113202889210813620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113202889210813620' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113202889210813620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113202889210813620'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-links.html' title='Oracle: Links'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113199117625969306</id><published>2005-11-14T09:45:00.000-08:00</published><updated>2005-11-14T09:59:36.273-08:00</updated><title type='text'>Oracle: Flashback</title><content type='html'>-- flashback doesn't work on system tablespace.( don't login as sys/system)&lt;br /&gt;&lt;br /&gt;- startup mount&lt;br /&gt;&lt;br /&gt;- alter database archivelog;&lt;br /&gt;&lt;br /&gt;- alter system set DB_FLASHBACK_RETENTION_TARGET=1440&lt;br /&gt;&lt;br /&gt;- alter system set DB_RECOVER_FILE_SIZE=512000000&lt;br /&gt;&lt;br /&gt;- alter database flashback on;&lt;br /&gt;&lt;br /&gt;- alter database open&lt;br /&gt;&lt;br /&gt;- flashback table "TEST" to before drop;&lt;br /&gt;&lt;br /&gt;-- two important things: SCN and 'Recycle Bin'&lt;br /&gt;show recyclebin;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113199117625969306?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113199117625969306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113199117625969306' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113199117625969306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113199117625969306'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-flashback.html' title='Oracle: Flashback'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113166503105614235</id><published>2005-11-10T15:22:00.000-08:00</published><updated>2005-11-10T15:23:51.080-08:00</updated><title type='text'>Oracle: Using Loop and Random</title><content type='html'>Create table test_normal (empno number(10), ename varchar2(30), sal number(10));&lt;br /&gt;&lt;br /&gt;Begin&lt;br /&gt;For i in 1..1000000&lt;br /&gt;Loop  &lt;br /&gt;    Insert into test_normal   &lt;br /&gt;              values(i, dbms_random.string('U',30), dbms_random.value(1000,7000));  &lt;br /&gt;    If mod(i, 10000) = 0 then  &lt;br /&gt;            Commit; &lt;br /&gt;    End if;&lt;br /&gt;End loop;&lt;br /&gt;End;/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113166503105614235?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113166503105614235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113166503105614235' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113166503105614235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113166503105614235'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-using-loop-and-random.html' title='Oracle: Using Loop and Random'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113114946586634554</id><published>2005-11-04T16:05:00.000-08:00</published><updated>2005-11-04T16:11:05.896-08:00</updated><title type='text'>Oracle: Histograms</title><content type='html'>When to use histograms:&lt;br /&gt;1. When the columns are used frequently in where clauses.&lt;br /&gt;2. it's hightly skewed data distribution.&lt;br /&gt;&lt;br /&gt;Creating Histograms:&lt;br /&gt;- execute DBMS_STATS.GATHER_TABLE_STATS&lt;br /&gt;                  ('scott','emp', METHOD_OPT =&gt; 'FOR COLUMNS SIZE 10 sal');&lt;br /&gt;  (  create a 10 bucket histograms on sal column of emp table)&lt;br /&gt;&lt;br /&gt;The default number of buckets is 75&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113114946586634554?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113114946586634554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113114946586634554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114946586634554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114946586634554'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-histograms.html' title='Oracle: Histograms'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113114541579883237</id><published>2005-11-04T14:47:00.000-08:00</published><updated>2005-11-04T15:03:35.820-08:00</updated><title type='text'>Oracle: Generation statistics</title><content type='html'>Oracle use following techniques to generates statistics:&lt;br /&gt;- Estimation based on random data sampling&lt;br /&gt;- Exact computation&lt;br /&gt;- User-defined statistics collection methods&lt;br /&gt;&lt;br /&gt;To collection statistics on schema&lt;br /&gt;- execute DBMS_STATS.GATHER_SCHEMA_STATS('OE',DBMS_STATS.AUTO_SAMPLE_SIZE);&lt;br /&gt;&lt;br /&gt;You can use DBMS_STATS to gather, modify, view, export, import and delete statistics.&lt;br /&gt;&lt;br /&gt;DBMS_STATS Package procedures:&lt;br /&gt;-  GATHER_INDEX_STATS      :      Index statistics&lt;br /&gt;-  GATHER_TABLE_STATS      :      Table, Columns and index statistics&lt;br /&gt;-  GATHER_SCHEMA_STATS  :       Statistics for all objects in a schema&lt;br /&gt;-  GATHER_DATABASE_STATS :    Statistics for all objects in a database&lt;br /&gt;-  GATHER_SYSTEM_STATS   :       CPU and I/O statistics for the system&lt;br /&gt;&lt;br /&gt;Gathering statistics on table/col/index will invalidate parsed SQL statements.&lt;br /&gt;Gathering system statistics will not invalidate parsed SQL.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Gather statistics. Gathering ends after 720 mins and is stored in mystats table&lt;br /&gt;    ** day time **&lt;br /&gt;   BEGIN&lt;br /&gt;   DBMS_STATS.GATHER_SYSTEM_STATS(&lt;br /&gt;                gathering_mode =&gt; 'interval',&lt;br /&gt;                interval =&gt; 720,&lt;br /&gt;                stattab = 'mystats',&lt;br /&gt;                statid =&gt; 'OLTP');&lt;br /&gt;    end;&lt;br /&gt;    /&lt;br /&gt;&lt;br /&gt;   ** night time **&lt;br /&gt;   BEGIN&lt;br /&gt;   DBMS_STATS.GATHER_SYSTEM_STATS(&lt;br /&gt;                gathering_mode =&gt; 'interval',&lt;br /&gt;                interval =&gt; 720,&lt;br /&gt;                stattab = 'mystats',&lt;br /&gt;                statid =&gt; 'OLAP');&lt;br /&gt;    end;&lt;br /&gt;    /&lt;br /&gt;&lt;br /&gt;- to import OLAP statistics for nighttime&lt;br /&gt;&lt;br /&gt;   BEGIN&lt;br /&gt;    DBMS_JOB.SUBMIT(:jobno,&lt;br /&gt;            'DBMS_STATIS.IMPORT_SYSTEM_STATS(''mysstats'',''OLAP'');'&lt;br /&gt;            SYSDATE +0.5, 'SYSDATE + 1');&lt;br /&gt;    COMMIT;&lt;br /&gt;  END;&lt;br /&gt;  /&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113114541579883237?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113114541579883237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113114541579883237' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114541579883237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114541579883237'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-generation-statistics.html' title='Oracle: Generation statistics'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113114405768349416</id><published>2005-11-04T14:35:00.000-08:00</published><updated>2005-11-16T15:58:39.596-08:00</updated><title type='text'>Oracle: Statistics</title><content type='html'>- Statistics is the data distribution and storage characteristics of tables, columns, indexes and partitions.&lt;br /&gt;- Selectctivity is the fraction of rows in a table that sql statement's predicate chooses.&lt;br /&gt;&lt;br /&gt;- Statistics generated include the following:&lt;br /&gt;  - Table statistics&lt;br /&gt;    - Number of rows&lt;br /&gt;    - Number of blocks&lt;br /&gt;    - Average row length&lt;br /&gt;  - Column statistics&lt;br /&gt;    - Number of distinct values in column&lt;br /&gt;    - Number of nulls in column&lt;br /&gt;    - Data distribution (histogram)&lt;br /&gt;  - Index statistics&lt;br /&gt;    - Number of leaf blocks&lt;br /&gt;    - Levels&lt;br /&gt;    - Clustering factor&lt;br /&gt;  - System statistics&lt;br /&gt;    - I/O performance and utilization&lt;br /&gt;    - CPU performance and utilization&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113114405768349416?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113114405768349416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113114405768349416' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114405768349416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113114405768349416'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-statistics.html' title='Oracle: Statistics'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113113027604950714</id><published>2005-11-04T10:44:00.000-08:00</published><updated>2005-11-10T15:45:54.246-08:00</updated><title type='text'>Oracle: setup sga_aggregate_targate</title><content type='html'>- in oracle9i, it intruduced a new feature sga_aggreate_targate/workarea_size_policy&lt;br /&gt;&lt;br /&gt;- sga_aggregate_targate will define how much memory will be allocated to sga for all sessions. if there're more user session, each session will be allocated less memory. if there're less user sessions, each session will be allocated more memory.&lt;br /&gt;&lt;br /&gt;- this eliminate tunning on hash_area_size, sort_area_size and so on.&lt;br /&gt;&lt;br /&gt;- how to set :&lt;br /&gt;set workarea_size_policy to auto&lt;br /&gt;set sga_aggregate_targate to 16% of physical memory on oltp and 40% of memory on dss system.&lt;br /&gt;&lt;br /&gt;- how measure the performance&lt;br /&gt;select * from v$pgastat&lt;br /&gt;over allocation count should be 0&lt;br /&gt;cache hit percent should be 100&lt;br /&gt;select name,value from v$sysstat where name like 'workarea exe%'&lt;br /&gt;one pass and multi pass should be zero&lt;br /&gt;&lt;br /&gt;- advisor feature in 9iR2&lt;br /&gt;v$pga_target_advice&lt;br /&gt;&lt;br /&gt;- how to query v$pga_target_advice&lt;br /&gt;to eliminate over_allocate:&lt;br /&gt;  select round(pga_target_for_estimate/1024/1024) as target_size_MB, &lt;br /&gt;             bytes_processed,estd_extra_bytes_rw as est_rw_extra_bytes, &lt;br /&gt;             estd_pga_cache_hit_percentage as est_hit_pct, &lt;br /&gt;             estd_overalloc_count as est_overalloc &lt;br /&gt;  from v$pga_target_advice;&lt;br /&gt;&lt;br /&gt;to eliminate extra reads/writes&lt;br /&gt;  select round(pga_target_for_estimate/1024/1024) as target_size_MB, &lt;br /&gt;             bytes_processed,estd_extra_bytes_rw as est_rw_extra_bytes, &lt;br /&gt;             estd_pga_cache_hit_percentage as est_hit_pct, &lt;br /&gt;             estd_overalloc_count as est_overalloc &lt;br /&gt;  from v$pga_target_advice;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113113027604950714?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113113027604950714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113113027604950714' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113113027604950714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113113027604950714'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-setup-sgaaggregatetargate.html' title='Oracle: setup sga_aggregate_targate'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113106906437823824</id><published>2005-11-03T17:48:00.000-08:00</published><updated>2005-11-03T17:51:04.393-08:00</updated><title type='text'>Oracle: what happened during hot backup</title><content type='html'>&lt;ol&gt;&lt;li&gt;Oracle checkpoints the tablespace, flushing all changes from shared memory to disk. &lt;/li&gt;&lt;li&gt;The SCN markers for each datafile in that tablespace are "frozen" at their current values. Even though further updates will be sent to the datafiles, the SCN markers will not be updated until the tablespace is taken out of backup mode. &lt;/li&gt;&lt;li&gt;Oracle switches to logging full images of changed database blocks to the redologs. Instead of recording how it changed a particular block (the change vector), it will log the entire image of the block after the change. This is why the redologs grow at a much faster rate while hot backups are going on. &lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113106906437823824?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113106906437823824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113106906437823824' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113106906437823824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113106906437823824'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/oracle-what-happened-during-hot-backup.html' title='Oracle: what happened during hot backup'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113106712986078394</id><published>2005-11-03T17:17:00.000-08:00</published><updated>2005-11-03T17:18:49.873-08:00</updated><title type='text'>TCPWrapper: logging</title><content type='html'>in hosts.deny add below entry to enable tcpwrapper logging to send email to admin&lt;br /&gt;&lt;br /&gt;ALL:All: spawn (echo '%h-%d' | mailx -s'%h-%d rejected on fcasun2' -r jamesp@synnex.com jamesp@synnex.com) &amp;amp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113106712986078394?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113106712986078394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113106712986078394' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113106712986078394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113106712986078394'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/tcpwrapper-logging.html' title='TCPWrapper: logging'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113105898933312005</id><published>2005-11-03T15:02:00.000-08:00</published><updated>2005-11-03T15:03:09.343-08:00</updated><title type='text'>Perl: automate sftp using perl or expect</title><content type='html'>&lt;p&gt;#!/usr/bin/perl -w&lt;/p&gt;  &lt;p&gt;use Net::SFTP;&lt;br /&gt;use strict;&lt;/p&gt;  &lt;p&gt;my $host = "host.ssh.com";&lt;br /&gt;my %args = (&lt;br /&gt;    user =&gt;  'your_user_name,&lt;br /&gt;    password =&gt;  'your_password',&lt;br /&gt;    debug =&gt; 'true'&lt;br /&gt;);&lt;/p&gt;  &lt;p&gt;my $sftp = Net::SFTP-&gt;new($host,  %args);&lt;br /&gt;$sftp-&gt;get("/home/user/something.txt",  "/home/user/hey.txt");&lt;br /&gt;$sftp-&gt;put("bar", "baz");&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;#!/usr/local/bin/expect&lt;/p&gt;  &lt;p&gt;spawn  sftp  -b cmdFile &lt;a href="mailto:user@yourserver.com"&gt;user@yourserver.com&lt;/a&gt;&lt;br /&gt;expect  "password:"&lt;br /&gt;send "shhh!\n";&lt;br /&gt;interact&lt;/p&gt;  &lt;p&gt;This will spawn sftp in batch mode and pass in the password shhh! to the  program. SFTP will than execute all the commads in cmdFile&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;cmdFile&lt;/strong&gt;&lt;br /&gt;lcd /home/ftp/test&lt;br /&gt;cd  /home/ftp/somedir&lt;br /&gt;mput *.dat&lt;/p&gt;  &lt;p&gt;lcd /home/recieving&lt;br /&gt;cd /home/someotherdir&lt;br /&gt;mget *.dat&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113105898933312005?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113105898933312005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113105898933312005' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113105898933312005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113105898933312005'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/perl-automate-sftp-using-perl-or.html' title='Perl: automate sftp using perl or expect'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113105391262353473</id><published>2005-11-03T10:51:00.000-08:00</published><updated>2005-11-03T13:38:32.646-08:00</updated><title type='text'>Enable tcpwrapper on solaris10</title><content type='html'>- on solaris 10, ssh, sendmail and rcpbind was tcpwrapper enabled by default&lt;br /&gt;  if there's no hosts.allow/deny files, it will grant access by default to all&lt;br /&gt;&lt;br /&gt;-To enable TCP Wrappers support for &lt;code class="small"&gt;inetd&lt;/code&gt;-based services, you can simply use the following commands:   &lt;pre class="small"&gt;# inetadm -M tcp_wrappers=true&lt;br /&gt;# svcadm refresh inetd&lt;br /&gt;&lt;br /&gt;# inetadm -l telnet | grep tcp_wrappers&lt;br /&gt;&lt;br /&gt;- you can also use svccfg to enable inetd based services.&lt;br /&gt;# svccfg -s inetd setprop defaults/tcp_wrappers=true&lt;br /&gt;# svcadm refresh inetd&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113105391262353473?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113105391262353473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113105391262353473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113105391262353473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113105391262353473'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/enable-tcpwrapper-on-solaris10.html' title='Enable tcpwrapper on solaris10'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113098211316942441</id><published>2005-11-02T17:38:00.000-08:00</published><updated>2005-11-02T17:41:53.183-08:00</updated><title type='text'>Korn Shell Global funcations</title><content type='html'>- create file get_time in directory ~/kfunctions&lt;br /&gt;   function get_time{&lt;br /&gt;       TIME=$(date '+%m/%d/%y')&lt;br /&gt;        printf "$TIME\n"&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;- create .kshrc file&lt;br /&gt;  export FPATH=/export/home/jamesp/kfunctions&lt;br /&gt;  autoload get_time&lt;br /&gt;&lt;br /&gt;- add entry to .profile&lt;br /&gt;  ENV=~.kshrc&lt;br /&gt;&lt;br /&gt;- use global functions&lt;br /&gt;  #!/bin/ksh&lt;br /&gt;  SYSTIME=$(get_time)&lt;br /&gt;  echo "$SYSTIME\n"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113098211316942441?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113098211316942441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113098211316942441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113098211316942441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113098211316942441'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/korn-shell-global-funcations.html' title='Korn Shell Global funcations'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113097900644823700</id><published>2005-11-02T16:37:00.000-08:00</published><updated>2005-11-02T16:51:16.473-08:00</updated><title type='text'>Perl: creating modules</title><content type='html'>- Perl is distributed with a program called h2xs. it will be used to generate skeletion files for a new module.&lt;br /&gt;&lt;br /&gt;- h2xs -AXc -n NewModule&lt;br /&gt;&lt;br /&gt;- edit NewModuel.pm&lt;br /&gt;&lt;br /&gt;- run perl Makefile.PL&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;&lt;br /&gt;- use NewModule&lt;br /&gt;NewModule-&gt;functions&lt;br /&gt;&lt;br /&gt;The &lt;span style="color:#990000;"&gt;Changes&lt;/span&gt; file is where you might keep track keep track of changes you make to your module as you write new versions&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000;"&gt;MANIFEST&lt;/span&gt; contains a list of files in this directory. If you add new files to the directory, you should also add them to the MANIFEST. The MANIFEST is used to create a tarball of your module for distribution, and it's also checked when people unpack the tarball and install the module&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000;"&gt;Makefile.PL&lt;/span&gt; is a Perl program used to create a Unix Makefile. You'll use this Makefile to test and install your module.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000;"&gt;NewModule.pm&lt;/span&gt; is your module. You'll write the code here in the next step.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113097900644823700?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113097900644823700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113097900644823700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113097900644823700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113097900644823700'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/perl-creating-modules.html' title='Perl: creating modules'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113089364629991913</id><published>2005-11-01T17:06:00.000-08:00</published><updated>2005-11-01T17:07:26.316-08:00</updated><title type='text'>Perl DBI and Loop</title><content type='html'>DBI and loops&lt;br /&gt;DBI statements are often used within loops that store or fetch data from a database. You might insert the contents of a text file into a database line by line, or read and parse multiple lines of output from a database query. I often see code like the following from new DBI programmers:&lt;br /&gt;&lt;br /&gt;foreach $line (&lt;file&gt;) {&lt;br /&gt;chomp $line;&lt;br /&gt;($alpha, $beta, $charlie, $delta) = split(/,/,$line);&lt;br /&gt;$sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values($alpha,$beta,$charlie,$delta)&lt;br /&gt;};&lt;br /&gt;$dbh = DBI-&gt;connect($dsn,'login','password');&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;$dbh-&gt;disconnect;&lt;br /&gt;}&lt;br /&gt;This code works, but not very efficiently. With the above code it took an hour to insert 200,000 rows into a MySQL database -- and MySQL is pretty fast! It might take half a day with Oracle.&lt;br /&gt;There are lots of improvements we can make. The first is just common sense: Never put anything in a loop that doesn't absolutely have to be there. For each of our 200,000 insertions, we connect to the database, prepare our SQL statement, execute it, and disconnect from the database. However, we only need to connect and disconnect once. We simply have to move our connect() and disconnect() outside the loop to drastically improve our performance: $dbh = DBI-&gt;connect($dsn,'login','password');&lt;br /&gt;foreach $line (&lt;file&gt;) {&lt;br /&gt;chomp $line;&lt;br /&gt;($alpha, $beta, $charlie, $delta) = split(/,/,$line);&lt;br /&gt;$sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values($alpha,$beta,$charlie,$delta)&lt;br /&gt;};&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;}&lt;br /&gt;$dbh-&gt;disconnect;&lt;br /&gt;This reduces our run time to half an hour, doubling our speed.&lt;br /&gt;Placeholders&lt;br /&gt;DBI allows us to further improve our code by using placeholders. We now connect and disconnect the database only once, but we still prepare and execute our SQL statement 200,000 times. The statement we prepare doesn't change much; all that changes is the insertion value. We can create a generic statement that we prepare only once, outside the loop. With this generic statement we can specify the insertion values at execution time. DBI uses a ? to define a placeholder, so our new SQL statement looks like this: $sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values(?, ?, ?, ?)&lt;br /&gt;};&lt;br /&gt;The statement is prepared the same as before: $sth = $dbh-&gt;prepare($sql);&lt;br /&gt;Now we can fill in each ? at execution time, once we fill in the ? values. There are two ways to do this. First, we can use the bind_param() subroutine to indicate what values to use: $sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values(?, ?, ?, ?)&lt;br /&gt;};&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;foreach $line (&lt;file&gt;) {&lt;br /&gt;chomp $line;&lt;br /&gt;($alpha, $beta, $charlie, $delta) = split(/,/,$line);&lt;br /&gt;$sth-&gt;bind_param(1, $alpha);&lt;br /&gt;$sth-&gt;bind_param(2, $beta);&lt;br /&gt;$sth-&gt;bind_param(3, $charlie);&lt;br /&gt;$sth-&gt;bind_param(4, $delta);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;}&lt;br /&gt;The bind_param() subroutine allows a data type as a third argument. Normally, this is used to tell the driver whether the placeholder is a number or a string: $sth-&gt;bind_param(1, $alpha, SQL_INTEGER);&lt;br /&gt;or $sth-&gt;bind_param(2, $beta, SQL_VARCHAR);&lt;br /&gt;The second way to specify values at execution time is to pass them directly as arguments to the execute statement: $sth-&gt;execute($alpha, $beta, $charlie, $delta);&lt;br /&gt;Using this method our code simplifies to: $dbh = DBI-&gt;connect($dsn,'login','password');&lt;br /&gt;$sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values(?, ?, ?, ?)&lt;br /&gt;}&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;foreach $line (&lt;file&gt;) {&lt;br /&gt;chomp $line;&lt;br /&gt;($alpha, $beta, $charlie, $delta) = split(/,/,$line);&lt;br /&gt;$sth-&gt;execute($alpha, $beta, $charlie, $delta);&lt;br /&gt;}&lt;br /&gt;$dbh-&gt;disconnect;&lt;br /&gt;Our code now takes twenty minutes to run. We achieved this improvement despite the fact that the MySQL database driver only emulates placeholders. Had this been a database that directly supports placeholders, such as Oracle, the improvement would have been even more dramatic. Placeholders are any easy way to improve your DBI coding, but there are a few gotchas that beginners need to avoid. First, notice that placeholders don't have quotes. This is correct: $sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values(?, ?, ?, ?)&lt;br /&gt;};&lt;br /&gt;This is not correct: $sql = qq{&lt;br /&gt;insert into $table (col_a, col_b, col_c, col_d)&lt;br /&gt;values('?', '?', '?', '?')&lt;br /&gt;};&lt;br /&gt;Placeholders cannot be used for column names or table names. This won't work: $sql = qq{&lt;br /&gt;select alpha, ? from table&lt;br /&gt;};&lt;br /&gt;Nor will this: $sql = qq{&lt;br /&gt;select alpha, beta from ?&lt;br /&gt;};&lt;br /&gt;Or even this: $sql = qq{&lt;br /&gt;select alpha, beta from table where ? &gt; 200&lt;br /&gt;};&lt;br /&gt;However, you can use Perl variables for column and table names: $sql = qq{&lt;br /&gt;select alpha, beta from $table where $col &gt; 200&lt;br /&gt;};&lt;br /&gt;You'll have to re-prepare this statement whenever you want to change the values of $table or $col.&lt;br /&gt;Fetches&lt;br /&gt;We've dealt mostly with inserting data into a database, so now we'll look at the ways DBI provides to get data out. Most of those ways follow the same basic format: $dbh = DBI-&gt;connect($dsn, 'login', 'passwd');&lt;br /&gt;$sql = qq{&lt;br /&gt;select * from $table&lt;br /&gt;};&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;while (@row = $sth-&gt;fetchrow_array) {&lt;br /&gt;print "@row\n";&lt;br /&gt;}&lt;br /&gt;$dbh-&gt;disconnect;&lt;br /&gt;The most efficient of these is fetchrow_arrayref():&lt;br /&gt;while ($row = $sth-&gt;fetchrow_arrayref) {&lt;br /&gt;print "@$row\n";&lt;br /&gt;}&lt;br /&gt;There's also fetchrow_hashref(), which stores the keys and values of the database into a hash: while ($ref = $sth-&gt;fetchrow_hashref) {&lt;br /&gt;foreach $key (keys %{$ref}) {&lt;br /&gt;print "$ref-&gt;{$key}, ";&lt;br /&gt;}&lt;br /&gt;print "\n";&lt;br /&gt;}&lt;br /&gt;Bind Columns&lt;br /&gt;Database fetches can be made even more efficient and elegant with the use of bind columns. Bind columns allow you to bind a variable to each column of a table, so that whenever a fetch is performed the bound variables are automatically updated: $sth-&gt;bind_columns(\%attr,@references_to_variables_to_bind);&lt;br /&gt;We can use it like this: $sql = qq{&lt;br /&gt;select alpha, beta, delta from table&lt;br /&gt;};&lt;br /&gt;$sth-&gt;prepare($sql);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;my ($alpha, $beta, $delta);&lt;br /&gt;$sth-&gt;bind_columns(undef, \$alpha, \$beta, \$delta);&lt;br /&gt;while ($sth-&gt;fetch) {&lt;br /&gt;print "$alpha - $beta - $delta\n";&lt;br /&gt;}&lt;br /&gt;Here, the fetch() subroutine is synonymous with fetchrow_arrayref(). This subroutine, combined with bind_columns(), is the fastest way to fetch data with DBI.&lt;br /&gt;Error Checking&lt;br /&gt;There's a big problem with all of code snippets you've seen in this article: We never check the return values of DBI methods. We simply assume that every DBI call was successful. The obvious solution is to add an or die clause after every DBI method call: $dbh = DBI-&gt;connect($dsn,'login','passwd')&lt;br /&gt; die $DBI::errstr;&lt;br /&gt;$sth = $dbh-&gt;prepare($sql)  die $dbh-&gt;errstr;&lt;br /&gt;$sth-&gt;execute  die $sth-&gt;errstr;&lt;br /&gt;However, there is a cleaner solution. Each DBI handle has a boolean attribute called RaiseError. If we set this to true, any errors triggered by that handle cause the script to die with an appropriate error message, saving us from having to check every DBI call we make. RaiseError can be set via the connect statement: $dbh = DBI-&gt;connect($dsn,'login','passwd',&lt;br /&gt;{ RaiseError =&gt; 1 });&lt;br /&gt;We can also call it after a connection is already made: $dbh-&gt;{RaiseError} = 1;&lt;br /&gt;Transactions&lt;br /&gt;I've found that many administrators shy away from using transactions with DBI. For those unfamiliar, transactions provide a way to group multiple SQL statements together so that database changes are only made if every statement is successful. For example, a transaction for updating a customer order database might include statements to update inventory, update accounts payable, and update shipping manifests. All updates must succeed; otherwise, we don't want to perform any of them. If only some of the updates succeeded, we might bill a customer for an order not shipped, or ship an order to a customer without billing them.&lt;br /&gt;Many administrators shy away from using DBI transactions.&lt;br /&gt;By default, DBI commits each statement as it's performed. To use transactions, we need to disable this behavior with the AutoCommit variable: $dbh = DBI-&gt;connect($dsn,'login','passwd', {&lt;br /&gt;RaiseError =&gt; 1,&lt;br /&gt;AutoCommit =&gt; 0,&lt;br /&gt;});&lt;br /&gt;We can also just say: $dbh-&gt;{AutoCommit} = 0;&lt;br /&gt;With AutoCommit off, changes are revocable until commit() is called. Uncommitted statements can be undone with rollback().&lt;br /&gt;Next, we need a way to group our statements that lets us test whether any failed. The easiest and most robust way to do this is to set RaiseError and wrap the statements in an eval block: $dbh-&gt;{RaiseError} = 1;&lt;br /&gt;eval {&lt;br /&gt;$sth_1-&gt;execute; # Update Inventory&lt;br /&gt;$sth_2-&gt;execute; # Update Accounts Payable&lt;br /&gt;$sth_3-&gt;execute; # Update Shipping&lt;br /&gt;};&lt;br /&gt;if ($@)&lt;br /&gt;$dbh-&gt;rollback;&lt;br /&gt;} else {&lt;br /&gt;$dbh-&gt;commit;&lt;br /&gt;}&lt;br /&gt;If any statement in the eval block fails, $@ is set and we revoke all three statements.&lt;br /&gt;Don't forget to commit your statements. If you do forget, what happens next depends on the database. Some databases automatically commit them; others roll them back.&lt;br /&gt;References&lt;br /&gt;The material for this article came from personal experience, a thousand or so readings of the DBI documentation and FAQ, and a generous review by DBI guru Tim Bunce. You can find the DBI module and its related documentation at &lt;a href="http://www.symbolstone.org/technology/perl/DBI" target="resource window"&gt;http://www.symbolstone.org/technology/perl/ DBI&lt;/a&gt;.&lt;br /&gt;__END__&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113089364629991913?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113089364629991913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113089364629991913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113089364629991913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113089364629991913'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/11/perl-dbi-and-loop.html' title='Perl DBI and Loop'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113081149423297254</id><published>2005-10-31T18:16:00.000-08:00</published><updated>2005-10-31T18:18:14.233-08:00</updated><title type='text'>Oracle Optimizer Operations</title><content type='html'>&lt;ol&gt;&lt;li&gt;Evaluation of expressions and conditions&lt;/li&gt;&lt;li&gt;Statement transformation&lt;/li&gt;&lt;li&gt;Choice of optimizer approaches&lt;/li&gt;&lt;li&gt;Choice of access paths&lt;/li&gt;&lt;li&gt;Choice of join orders&lt;/li&gt;&lt;li&gt;Choice of join methods&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113081149423297254?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113081149423297254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113081149423297254' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113081149423297254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113081149423297254'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/oracle-optimizer-operations.html' title='Oracle Optimizer Operations'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113081133812643760</id><published>2005-10-31T18:05:00.000-08:00</published><updated>2005-10-31T18:15:38.150-08:00</updated><title type='text'>Oracle Hash Join and nested join</title><content type='html'>- In a nested loop join, the database reads and index, builds a list of ROW ID’s and then probes into the second table for the matching rows.&lt;br /&gt;&lt;br /&gt;-In a hash join, the database does a full-scan of the driving table, builds a RAM hash table, and then probes for matching rows in the other table.  For certain types of SQL&lt;br /&gt;&lt;br /&gt;-The propensity of the SQL optimizer to invoke a hash join is heavily controlled by the setting for the &lt;span style="color:#990000;"&gt;hash_area_size&lt;/span&gt; Oracle parameter&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113081133812643760?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113081133812643760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113081133812643760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113081133812643760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113081133812643760'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/oracle-hash-join-and-nested-join.html' title='Oracle Hash Join and nested join'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113080678871900036</id><published>2005-10-31T16:30:00.000-08:00</published><updated>2005-10-31T16:59:48.730-08:00</updated><title type='text'>Oracle Plan Table</title><content type='html'>use UTLXPLAN.SQL to create PLAN_TABLE&lt;br /&gt;use UTLXPLS.SQL to generate report.&lt;br /&gt;use command "explain plan for my-sql-statement"&lt;br /&gt;    or "explain plan into table_name for my-sql-statement" to generate execution plan&lt;br /&gt;&lt;br /&gt;The fields (attributes) within the plan table&lt;br /&gt;- the most important fields with in plan table are:&lt;br /&gt;     &lt;em&gt;operation, option, object_name, id&lt;/em&gt; and &lt;em&gt;parent_id&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;select   substr (lpad(' ', level-1)  operation  ' ('  options  ')',1,30 ) "Operation",   object_name                                                              "Object"&lt;br /&gt;from   plan_table&lt;br /&gt;start with id = 0&lt;br /&gt;connect by prior id=parent_id;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113080678871900036?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113080678871900036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113080678871900036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113080678871900036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113080678871900036'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/oracle-plan-table.html' title='Oracle Plan Table'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113080500880918549</id><published>2005-10-31T16:19:00.000-08:00</published><updated>2005-10-31T16:30:08.863-08:00</updated><title type='text'>Oracle SQL Processing</title><content type='html'>sql processing use the following main components to execute a SQL query&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The parser checks both syntax and semantic analysis&lt;/li&gt;&lt;li&gt;The Optimizer uses costing methods, cost-based optimizer(CBO), or internal rules, rule-based optimizer(RBO), to determine the most efficient way of producing the result of the query.&lt;/li&gt;&lt;li&gt;The Row Source Generator receives the &lt;span style="color:#990000;"&gt;optimal plan&lt;/span&gt; from the optimizer and outputs the &lt;span style="color:#990000;"&gt;execution plan&lt;/span&gt; for the SQL statement.( execution plan defines how oracle finds or writes the data. For example, an important decision that Oracle has to take is if it uses indexes or not. And if there are more indexes, which of these is used.)&lt;/li&gt;&lt;li&gt;The &lt;span style="color:#990000;"&gt;SQL Execution Engine&lt;/span&gt; operates on the &lt;span style="color:#cc0000;"&gt;execution plan&lt;/span&gt; associated with a SQL statement and then produces the results of the query.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113080500880918549?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113080500880918549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113080500880918549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113080500880918549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113080500880918549'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/oracle-sql-processing.html' title='Oracle SQL Processing'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113026893152598666</id><published>2005-10-25T12:34:00.000-07:00</published><updated>2005-10-25T12:35:31.526-07:00</updated><title type='text'>oracle how to retrieve sid information</title><content type='html'>Method 1 (for Oracle 7.x and up)&lt;br /&gt;    SELECT sid FROM V$SESSION         WHERE audsid = userenv('sessionid');&lt;br /&gt;&lt;br /&gt;Method 2 (for Oracle 8i and up - uses new function SYS_CONTEXT)&lt;br /&gt;    SELECT sid FROM V$SESSION         WHERE audsid = SYS_CONTEXT('userenv','sessionid');&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113026893152598666?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113026893152598666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113026893152598666' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113026893152598666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113026893152598666'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/oracle-how-to-retrieve-sid-information.html' title='oracle how to retrieve sid information'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113019690926576367</id><published>2005-10-24T16:34:00.000-07:00</published><updated>2005-10-24T16:48:05.253-07:00</updated><title type='text'>Analyze snappack output on oraperf website</title><content type='html'>&lt;a href="http://www.oraperf.com/"&gt;http://www.oraperf.com/&lt;/a&gt;&lt;br /&gt;login: jamesp&lt;br /&gt;&lt;br /&gt;&gt; set line 500&lt;br /&gt;&gt; set serveroutput on&lt;br /&gt;&gt; execute oraperf.analyze_lio(10,2);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113019690926576367?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113019690926576367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113019690926576367' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113019690926576367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113019690926576367'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/analyze-snappack-output-on-oraperf.html' title='Analyze snappack output on oraperf website'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-113017485845906442</id><published>2005-10-24T10:27:00.000-07:00</published><updated>2005-10-24T10:27:38.466-07:00</updated><title type='text'>Server log monitoring</title><content type='html'>use logsurfer or swatch to monitor server log files.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-113017485845906442?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/113017485845906442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=113017485845906442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113017485845906442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/113017485845906442'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/10/server-log-monitoring.html' title='Server log monitoring'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10040867.post-110524472128196224</id><published>2005-01-08T20:19:00.000-08:00</published><updated>2005-01-08T20:25:21.280-08:00</updated><title type='text'>Setup Sun StorEge 3510 disk array</title><content type='html'>1) turn on point to point mode (default is loop mode)&lt;br /&gt;2) turn on auto failover back&lt;br /&gt;3) choose random mode ( default is sequencial mode)&lt;br /&gt;4) create at least one spare disk&lt;br /&gt;5) create two logical drive and assign one drive to primary controller and another drive to secondary controller&lt;br /&gt;6) create partitions on logical drive&lt;br /&gt;7) map host LUN&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10040867-110524472128196224?l=jamespei.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jamespei.blogspot.com/feeds/110524472128196224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10040867&amp;postID=110524472128196224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/110524472128196224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10040867/posts/default/110524472128196224'/><link rel='alternate' type='text/html' href='http://jamespei.blogspot.com/2005/01/setup-sun-storege-3510-disk-array.html' title='Setup Sun StorEge 3510 disk array'/><author><name>James Pei</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
