diff --git a/1401.html b/1401.html new file mode 100644 index 0000000..4e3e1fc --- /dev/null +++ b/1401.html @@ -0,0 +1,144 @@ + + + + + + + + +SECTION I -- INTRODUCTION + + + + + + +
+ +

SECTION I -- INTRODUCTION

+ +

Chapter 1: A Brief +History of Oracle -- Dave Ensor

+ +

Chapter 2: Oracle and the +OakTable – Mogens Nørgaard

+ +

SECTION II – PERFORMANCE +AND TESTING

+ +

Chapter 3: You Probably +Don't Tune Right – Mogens Nørgaard and Anjo Kolk

+ +

Chapter 4: Waste not, +Want Not – Connor McDonald

+ +

Chapter 5: Why I Invented +YAPP – Anjo Kolk

+ +

Chapter 6: Extended Trace +Data – Cary Millsap

+ +

Chapter 7: Direct Memory +Access – Kyle Hailey

+ +

Chapter 8: Compulsive +Tuning Disorder – Gaja Vaidyanatha

+ +

Chapter 9: Testing and +Risk Management – David Ruthven

+ +

SECTION III – +ARCHITECTURE AND SCALABILITY

+ +

Chapter 10: Hardcore +Parallel Server – James Morle

+ +

Chapter 11: The RAC +Revolution – James Morle

+ +

Chapter 12: Join The +BAARF Party (or not) -- Mogens Nørgaard and James Morle

+ +

SECTION IV – DON'T TRY +THIS AT HOME…

+ +

Chapter 13: Dreadful +Design – Jonathon Lewis

+ +

Chapter 14: Bad CaRMa -- +Tim Gorman

+ +

Chapter 15: Blackbox Mayhem +-- Tom Kyte

+ +

 

+ +
+ + + + diff --git a/1762.pdf b/1762.pdf new file mode 100644 index 0000000..2913e4c Binary files /dev/null and b/1762.pdf differ diff --git a/2477.html b/2477.html new file mode 100644 index 0000000..177b830 --- /dev/null +++ b/2477.html @@ -0,0 +1 @@ + Errata for 582-3 Asleson (corrected in the second printing)

Errata 387-1 Norgaard (corrected in the 2nd printing)

Page

Original Sentence

Corrected Sentence

iii

 

(Chapter 5 listing is missing)

Chapter 5 Extended SQL Trace Data..........................................155

xxv

In 2003 it was Steve Adams (perhaps the most knowledgeable person in the world when it comes to Oracle internals), and in 2004 it was Tom Kyte, the master of http://askTom.rracle.com.

 

In 2003 it was Steve Adams (perhaps the most knowledgeable person in the world when it comes to Oracle internals), and in 2004 it was Tom Kyte, the master of http://askTom.oracle.com.

 

194

I didnÕt have the time to start working on my own version of m2 straight away, and then was sidetracked for several months into investigation of a new program called the Oracle trace facility, which I was introduced to in Denmark, during Jonathan LewisÕs Masters Class in February 2002.

I didnÕt have the time to start working on my own version of m2 straight away, and then was sidetracked for several months into investigation of a new program called the SQL trace facility, which I was introduced to in Denmark, during Jonathan LewisÕs Masters Class in February 2002

 

\ No newline at end of file diff --git a/3871_Ch07_Source_Code.txt b/3871_Ch07_Source_Code.txt new file mode 100644 index 0000000..152ef67 --- /dev/null +++ b/3871_Ch07_Source_Code.txt @@ -0,0 +1,50 @@ +/* Query displaying the version number of components installed in this release of Oracle */ +SQL> select * from v_$version; + + +/* Query displaying the number of wait events in this release */ +SQL> select count(*) from v_$event_name; + +/* Query displaying the various wait classes and the number of wait events in each class */ +SQL> select wait_class, count(*) from v_$event_name group by wait_class; + +/* Query the various wait classes and the number of wait events in each class */ +SQL> select view_definition from v_$fixed_view_definition where view_name = 'GV$ACTIVE_SESSION_HISTORY'; + +/* Query providing wait details and SQL details from ASH for a foreground user, DEMO_USER, in the previous 3 3/4 minutes */ +SQL> select ash.user_id "USER", e.name "EVNAME", e.wait_class "EVCLASS", ash.twait_msecs"TWAIT_MSECS", ash.obj# "OBJ#", ash.file# "FILE#", s.sql_text "SQL" from v_$sql s, v_$event_name e, ( select user_id, sql_id "SQL_ID", sql_plan_hash_value, sql_opcode, seq#, event#, p1, p2, p3, time_waited/1000 "TWAIT_MSECS", current_obj# "OBJ#", current_file# "FILE#", current_block# "BLOCK#" from v_$active_session_history where session_type <> 'BACKGROUND' and (session_id,session_serial#) in +( select sid,serial# from v_$session where username = (upper('&&oracle_user_name'))) +and wait_time = 0 and event# <> 0 and sample_time between sysdate-(0.125/24) and sysdate) ash +where s.sql_id = ash.sql_id and e.event# = ash.event#; + +/* Query displaying the breakdown of wait time in milliseconds for all events beginning with the string db file and having an occurrence frequency of 100 times or higher. */ +SQL> select event, wait_count, wait_time_milli from v$event_histogram where event like 'db file%' and wait_count > 100 order by event, wait_time_milli, wait_count + +/* Query displaying session wait details */ +SQL> select event, seq#, sid, p1, p2, p3, wait_time from v_$session_wait where state = 'WAITED KNOWN TIME'; + +/* Query displaying details from Active Session History (ASH) */ +SQL> select sid, event, wait_count, wait_time from v_$session_wait_history where event# not in (select event# from v$event_name where wait_class in ('Idle','Other')); + +/* Query displaying user and process information */ +select s.username, p.spid, s.sid, s.serial# from v_$session s, v_$process p +where s.paddr = p.addr and p.spid =; + +SQL> set linesize 132 +SQL> col event format a40 +SQL> col avg_wait_secs format 99.9999 +SQL> col wait_secs format 9999.9999 +SQL> col connection_time format 9999.9999 +SQL> undef oracle_sid_number +SQL> +SQL> select se.event, (se.average_wait/100) AVG_WAIT_SECS, sum(se.total_waits) TOTAL_WAITS, sum(se.time_waited/100) WAIT_SECS, st.connection_time_secs CONNECTION_TIME, (sum(se.time_waited/100)/st.connection_time_secs * 100) PERCENT_OF_CONNECTION_TIME +from v_$session_event se, (select ((sysdate-logon_time)*24*60*60) CONNECTION_TIME_SECS +from v_$session where sid = &&oracle_sid_number ) st /* -1 needs to be added if relevant */ +where se.sid = &&oracle_sid_number /* -1 needs to be added if relevant */ +group by se.event, se.average_wait/100, st.connection_time_secs +order by 4 desc; + +/* Query details from session wait history */ +SQL> select sid, event, wait_count, wait_time from v_$session_wait_history where event# not in (select event# from v$event_name where wait_class in ('Idle','Other')); + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..94c3273 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2004 Cary Millsap, Anjo Kolk, Connor McDonald, Tim Gorman, Kyle Hailey, David Ensor, Jonathan Lewis, Gaja Krishna Vaidyanatha, David Ruthven, and James Morle + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1302f81 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Oracle Insights*](http://www.apress.com/9781590593875) by Cary Millsap, Anjo Kolk, Connor McDonald, Tim Gorman, Kyle Hailey, David Ensor, Jonathan Lewis, Gaja Krishna Vaidyanatha, David Ruthven, and James Morle (Apress, 2004). + +![Cover image](9781590593875.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file diff --git a/program1.txt b/program1.txt new file mode 100644 index 0000000..3e78c28 --- /dev/null +++ b/program1.txt @@ -0,0 +1,37 @@ +#include +#include +#define N 20 + +/* structure definition: */ +struct foo +{ + int id; + int a; + int b; + int c; +}; +/* end structure defintion */ + +main() +{ +struct foo foo[20]; +int fptr; + + memset(foo,0,sizeof(foo)); + /* record 1 */ + foo[0].id=1; + foo[0].a=11; + foo[0].b=12; + foo[0].c=13; + /* record 2 */ + foo[1].id=2; + foo[1].a=21; + foo[1].b=22; + foo[1].c=23; + + if ((fptr = open("foo.out",O_WRONLY | O_CREAT,0777)) < 0 ) + return -1; + write(fptr,foo,sizeof(foo)); + return 0; +} + diff --git a/sga_attach.txt b/sga_attach.txt new file mode 100644 index 0000000..dbc89a6 --- /dev/null +++ b/sga_attach.txt @@ -0,0 +1,69 @@ + #include + #include + #include + #include + #include "event.h" + + #define SGA_BASE 0x80000000 /* SGA BASE ADDRESS */ + #define KSUSECST_ADDR 0x85251EF4 /* START ADDR of KSUSECST */ + #define SESSIONS 150 /* NUMBER of ROWS/RECORDS in */ + #define RECORD_SZ 2328 /* SIZE in BYTES of a ROW in */ + + #define KSUSSSEQ 1276 /* offset 1276 size 2 */ + #define KSUSSOPC 1278 /* offset 1276 size 2 */ + #define KSUSSP1R 1280 /* offset 1280 size 4 */ + #define KSUSSP2R 1284 /* offset 1284 size 4 */ + #define KSUSSP3R 1288 /* offset 1288 size 4 */ + + main(argc, argv) + int argc; + char **argv; + { + void *addr; + int shmid; + int shmaddr; + void *current_addr; + long p1r, p2r, p3r, sqla; + unsigned int i, seq, tim, flg, evn; + + if (argc != 2) { + fprintf(stderr, "Usage: %s shmid \n", *argv); + exit(1); + } + + /* ATTACH TO SGA */ + shmid=atoi(argv[1]); + shmaddr=SGA_BASE; + if ( (void *)shmat(shmid,(void *)shmaddr,SHM_RDONLY) == (void *)-1 ) { + printf("shmat: error attatching to SGA\n"); + exit(); + } + + + /* LOOP OVER ALL SESSIONS until CANCEL */ + while (1) { + current_addr=(void *)KSUSECST_ADDR; + sleep(1); + printf("^[[H ^[[J"); /* clear screen */ + printf("%4s %8s %-20.20s %10s %10s %10s \n", + "sid", "seq", "wait","p1","p2","p3"); + for ( i=0; i < SESSIONS ; i++ ) { + seq=*(unsigned short *)((int)current_addr+KSUSSSEQ); + evn=*(short *) ((int)current_addr+KSUSSOPC); + p1r=*(long *) ((int)current_addr+KSUSSP1R); + p2r=*(long *) ((int)current_addr+KSUSSP2R); + p3r=*(long *) ((int)current_addr+KSUSSP3R); + if ( evn != 0 ) { + printf("%4d %8u %-20.20s %10X %10X %10X \n", + i, + seq, + event[evn] , + p1r, + p2r, + p3r + ); + } + current_addr=(void *)((int)current_addr+RECORD_SZ); + } + } + }