Вы находитесь на странице: 1из 435

Oracle Press"

&
&*

THE

AUTHORIZED

Oracle Press
EDITIONS
O N L Y

F R O M

8RNE I

Oracle



Quest Software

Oracle
Verizon Information Services
. -

Chameleon Technology
:

Hotsos LLC


Oracle 7.3 8/

ORACLE

Oracle Press

Oracle Performance
Tuning 101

Gaja Krishna Vaidyanatha,


Kirtikumar Deshpande, and
John Kostelac

Osborne/McGraw-Hill

TM

Oracle 101

""

Gaja Krishna Vaidyanatha, Kirtikumar Deshpande, and John Kostelac


Oracle Performance Tuning 101
Copyright 2001 by The McGraw-Hill Companies. All rights reserved.
Osborne/McGraw-Hill
2600 Tenth Street
Berkeley, California 94710
U.S.A.
ISBN 0-07-213145-4
,
Oracle 101:
.
.
.
.

"", 2003
. N : 1(03)
N : 070612 30.09.97 .
ISBN 5-85582-195-1
28.05.2003. 70x100/16.

.. 27. 3200. N 281

""
, 123100, ., . 13/6, . 1 (. )
: (095) 256-02-83
: (095) 259-01-62
www.lory-press.ru
" "
109044, , . . 18


Quest Software.

. Oracle.
Quest
SWAT Oracle
Andersen Consulting.
Oracle, Oracle.
, , .
, Oracle. ,
Oracle-L. , . . IOUG-A Master Class
Univercity. gajav@yahoo.com
() 20 ,
Oracle. ,
.
Oracle
Verizon Information .Services
Oracle-L LazyDBA. kirti_deshpande@hotmail.
com.

,
; , ;
, - ;
, ;
,
, ...

,
.


. .
.

. . .

Oracle

?
?
?
?
?

6
7
8
9
10

13

?
?
Oracle 101


Oracle






3 7 ,

16
18
19
20
22
30
. 45
46
54
55
55
55
55

VIII

II

3 ,

59

Oracle .
62
: ,
63
,
?
64
, , :

65
:
66
.
67
: ,

.
. 67

67

68

Oracle
. . 68
""?
69
?
70

72
?
72
?
. . . . . . . . . . 72
?
. . .
73

74
?
. 78
,
79

. . . . ... . . 7 9
?
79
?
80
.
81
?
85

88
SQL
. . .
89
SQL
98
SQL . . . . . . . . . . . . 99

4
"" SQL

105

SQL
107
SQL?
107
?. . . . . 1 1 1
tkprof . . . . *.. . . . . . . . . 112

IX

tkprof
115
Oracle ?.
116
Oracle? .
117
, - ?
118
AUTOTRACE? . . . . . . . . . . . . . . . . . . . . . . . . 119

III

5

123
Oracle


.
SQL:
ENTER?

: . . . . . . . . . . . . .




Java
SPA

:
ORA-04031
?.
OR-04031 Oracle 7.3 . . . . . . .
, . . .

126
127
131
134
136
138
139
139
140
141
141
142
143
149
151
151
153
154

157
,
, ?
160

161
OracleSi . . 161
OracleSi
. .

164

. .
. . . . . . . . 165

V .'. . . . . . . . . . . . . . 166

. . . . . . . . . . . . . . . . . . 166
. . .
167

168
cache . . .
168



. . . . .>. .
?
, . . . .

,

. .

169
169
171
172
173
174

7 177

179
,

183
, . . . . 184
, . . . 185

.
187

187

. . .
189

190
. . . . 191
Oracle
193
,

193

197


'
200
. . . . 200
Oracle?
201
:
205
:

205

207
pctused
207
pctfree
208
initrans
209
maxtrans
210
freelists
211
,

212


213

.219


220


>
221

XI

223
224
225
228
229
230

IV

9

235


236

237

238
SQL, . . . 243
,
245
PARALLEL_MIN_SERVERS,
,
PARALLEL_MAX_SERVERS PARALLEL_MIN_PERCENT
247

249
DML
251
PDML
251
PDML
252
PDML
253

254

10

257

Oracle
: , ?

259
260


?

. . . . .


?
"ORA-01555.- Snapshot too old"
.


260
261
263
266
269
270
271
274
277
277

281

279

XII

V

11 /

287

RAID
. . . . . . . . . . . . 289
RAID
290
RAID
. v . . . . . . 291
RAID
293

. . . . . . ' . . . . . . . 293

. . . . . . . . / . .4 . . ; . . . 294
:

. .... 295

296
TnnbiRAID
.
296
RAID
296
Oracle RAID.
. , . . . . . . . 303
. . . . . . . . . . . 308

. .
309
, 1
311

312
, 2
314

315
"" :

316
/
317

317
,

317
. ' . . . . . . . 318


318
""
319
? . .
319
,
/
320
RAID Oracle: . . . . . . . . . . . . 321
RAID
. . . . . . . . . . . . 323

12
:
RAM
'.'.


() SGA Oracle . . . . . . ' . . . . . .
UNIX
.

329
331
332
334
335
336
336
337

XIII
Solaris
/
SGA

AIX
;
/
SGA
,..:.,
.

.
HP-UX
.....
/
SGA


Windows NT
Windows NT



Windows NT . . . . . .
"No Windows Dressing"
( !)
. .
(startup starting)? . . . . . . . . . . . . . . .

13

340
341
342
343
344
344
347
348
350
352
352
353
354
355
356
357
357
359
359
359
360

361

Oracle:
362
Oracle?
362
,
362
:
.
364

365

366
. . . . . . . . . . . 367

368
. . . . . . . . . .
369

370
/
.372

. . . . . . . . . . . . 374
...
375

VI

379
393
405

. Oracle,
" "? , ,
. .
Oracle, , 1989 ., , "" Oracle.
, ,
, 50% , . , Oracle 20%
, . ,
, , , Oracle.
. , Oracle
, , ,
, . ?
, Oracle
. , ,
, . , ,
Oracle.

Oracle 101:

XV

, ,
, , , , 10 ,
Oracle.
Oracle,
, .
"Oracle 101: " . , , , ,
, . ,
Oracle . ,
(rebuilding) , . ,
,
, 99- , .

" Oracle 101" Oracle,
hotsos.com. " " (performance by
accident). 1999 . Hotsos, Miracle A/S


Oracle. , "Oracle 101: "
.
,
hotsos.com

I
I

26 1990 . -, 24 .
; ,
,
, .
. .
, ,
, , , .
.
.
, ,
. , , . ,
. !

, .
. .
, .. (),

Oracle <01:

XVJi

, , . - - , . ,
,
VAX . . - , , ,
,
. .
Oracle 1992 . Owens-Corning
Fiberglas Corporation , . . Oracle
6.0.31 .
, ,
Oracle, /, TCP/IP .
, ,
Owens-Corning ,
, Oracle. Oracle. , , ,
. . , .
. .
,
.
, Oracle.
, , , ,
, ,
, , .

Oracle, OraPub (http://www.orapub.com)
Hotsos LLC (http://www.hotsos.com), .
, . .
Alliance Data Systems ,
Information Control Corporation, STATSPACK .
.
Oracle-L
1997 . . , -

XVJii

Oracle 101:

, . , IOUG-A 2000.
, Oracle Acquisitions, Osborne/McGraw-Hill, , . (developmental editor)
. , ,
. .
Osborne/
McGrawHill. ,
. , , . ,
2000 . ,
.
Osborne, ,
, .
1997/1998 .
Oracle-L, , .
.
, , , .
,
, StorageXpert for Oracle
( Quest Software),
.
Quest .
,
. , .
, , ,
, .

1, 2 5-7.
, , , .
, . , . .
, .
.

Oracle 101:

XJX

, ,
, , , . , ,
. , . .
i
, , . ,
, , , . ,
. ,
.
, . .
1994 . COBOL,
, Oracle UNIX.
Oracle, UNIX PROGRESS.
Integrated Medical Networks (IMN). Oracle,
UNIX . IMN, . .
, , Oracle Oracle-L lazyDBA (http://www.lazyDBA.com). ,
. ,
. , .
,
Oracle-L. Oracle-L, , ,
. 1997 .,
Oracle-L, .
" " , .
', lazyDBA. ,
,

web-.
Osborne/McGraw-Hill, . ,

XX

Oracle 101:
, ,
.

. , .
, .
Oracle-L
IOUG-A Live!
, ,
.
,
. . ,
, .
,
. . , , , ,
,
.


Oracle,
Oracle (IOUG) Americas
Live! 2000, Oracle Open World 2000.
, , Oracle, 40 . ,
, 400 .
!
,
. , Oracle, , ,
Oracle 8.1.7.
, ,
, . , , .
, , .


, , . ,
( -

XXJi

,,

, ). "
Oracle" (Oracle Performance Management), , ,
. , - .
, ,
Oracle " "
() Oracle, . , ,
,
.
.
, .
( 70 ) .
, .
$. , ? , .
. !


, - . ,
. ,
. , , - ,
.
. , , . 11
12 .
.
.
'

1:
, -

Oracle 101:

xxiii

Oracle.
, Oracle.

2:

, ,
. , , ,
SQL, ,
SQL . , SQL
tkproof, explain plan autotrace. ,
, , .

3:


Oracle. , , Oracle,

Oracle.
, , .

4:

. . . ,

, .

5:

Oracle ,
Oracle. 11 RAID
/, - , , Oracle RAID.
12
Oracle. , UNIX Microsoft Windows NT,

XXJV

Solaris, HPUX, AIX Windows NT. ,


11 12 , Oracle.

6:

: , .
: ,
SQI?Loader Oracle. , .
. , web-,
.
: , . URL-
.

...

Oracle


, , ,
.

,
( , ),
.
, /,
. ,
, ,
/, .
,
/. ,
, .

J Lo6po Oracle.
Oracle
, , . ,
, Oracle .
( ) , , Oracle , . ,
.
,
.
Oracle. , . ,
, ,
,
Oracle. " "

Oracle
Oracle. He
, .
. , .
, ,
- . : " ? ? ?
?" , - : " , ?" : "
Oracle?", , , , , . , , ,
. .
, Oracle,
. , Oracle.
( , ) " ", . ,
,
Oracle,
.
, Oracle,
, Oracle 7.3 . , (, ).
,
, SQL (,
). , , .

Oracle .
Oracle . () .
, -,
, , . -

, www.orapub.com .
(Craig A.Shallahammer. Total Performance Management (An introduction to the method)).
, Oracle, , (" "),
. ,
"" .
.
, , , , , ,
.
,
, . ,
.

?
, .
Oracle , . .
.

Oracle , , . .
, , .
, ,
,
.
. ,
.

Oracle
, . ,
. ,
(striping) /. , NFS
(, ). , , ?
SQL ,
, .
.

?
, ? . - , . .
, , . ,
,
. , ,
. , .
, . , , ? .
.
,
.
. , ( - ),
. , .
,

.
,
: ,

1
, , .
, "".
, Oracle . . , - , .
.
:
, , ,
.
,
. , ,
, , , .
: , , , .

?
, .
()
, . ,
, .

.
,
( ) .
, ,
. , ( )
Oracle ,
. , . , ,
, , . ,
. , .
Oracle, ,
, ,
.

Oracle

, , - , .
. , ,
, .

?
, . (
) , . , ,
(CTD, Compulsive Tuning Disorder). ,
. -
CTD , !
,
, ,
.
. , .
-
.
, " , //, , ,
". , ,
, ,
(
). , , .
, . ,

.
! Oracle (
), . (cache-hit-ratio)
23. 281

99 99,99%? : ! , , (, 70%)
.
: " ?"
, /
, ,
. ,
,
. ,
/ (get/miss).
.

, , . , , , .

.
? .

?
Oracle, ( ). ,
. , , "".
.
, , .
, . , . , .
, ',
. ,
. , , ,
. ,
, , . , ,
.

Oracle

11

Oracle.
,
, . , Oracle
, ,
. ,
, "- ...". , ,

. ,
, . , , .
, , . ,
. , ,

, . ( , , , ,
, . , , !)
: " ?" , .

, .
, .
.
, . -,
,
. ,
. , ,
,
. , , (,
(paging), ).
, ,
. , , ,

12

1
.
,
.
, .
, . ,
, 30
15 , .
15 (, , ), ,
, .

,
.
. ,
, .

14

,
, / ()
, . .
, ,
. , Oracle (OSGA, Oracle
System Global Area).


Oracle
(, 99,999%), Oracle .

. , .
, ,
, . ( ) , /,
,
DATA INDEX.
Oracle, . Oracle , .

15


Oracle. Oracle, . Oracle
, . ,
.
, , , ,
. Oracle : , .
. ,
. .

, ( ) . '
, . ,
(, , ),
. , , ,
, . ,
, , .
, .
http://www.hotsos.com/ " : ".
Oracle : () .
.
, , () , .
, -

16

2
, ,
, ,
/,
RAID. , Oracle.
.
, ( ,
). ,
.
, , ,
.
. , .

.

, .
, .

. ,
. , .
,
Oracle, .


?
, ,
.
.
. .
, "".

17

. ,
. ,
, , .
,
Oracle . : .
, , .
- . , ,
Oracle, . . ,
,
Oracle (SGA, Oracle System Global Area) , .
, SGA,
, .
,
. , , , : :
( 90%)
.
.
.
. Oracle
, .
, SQL

( , Oracle ,
).

18

2
, (-
, , !), ,
, , , ,
.
, , " 99,999%" . (CTD), 1!
, ,
.
, .
, , : . , .

?
, ,

Oracle. , , ,
,
. ,
. :



( )


( )
,
,
. . ,
. , ,

19

. . ()
,
.
,
(DML, Data Manipulation Language) , .

,
, . , . , ,
"---, . ", .


Oracle 101

Oracle, ""
( "", . .
.). . , ( ""), Oracle
( ""). "", . , , , ,
. , , , . ,

, . , :
1. .
2. .
3. Oracle
( Oracle, SQL
).
4. .
5. (, ,
/, , . .).
6. .

20

____

7. .
8. 3 7 ,
.
, , . . : ,
. , ? !
, ,
.
, .
.
, , ,
. ,
.
.

, ,
, , .
, , .
,
/
.
, .
: . : " " . , ,
, , .
, - , ,
.
, , . -

,
, , . ,
, .

,

.
.

,
(//), , _
(//).

( ),

.

, . !
, , , , , .

.
, , . .
?

,
. ,
:
1. ,

2. ( ),

3.
,
( ) - ,
.

22

2
( ) , ()
. ,
, .

, . ,
. ,
, .
, , .

( 2) ( 3
4) . ,
, . , .
.
, ,
. , , , . ? .
? . , ,
, , .
Oracle. ,
, , , .
, 100%- .
.
(snapshots) , , , , . , , ,
, .

23

, 8 - 10:0010:30 . (
11:30 13:00) 15:30,
17 . ,
.
, , 12 . . , .
, . , , , .
: .
, SGA
- . - . Oracle
, ,
. , , ,
, .
, ,
, . ,
. ,
. , ,
, , - .
, , , , .
Oracle : 15- . ,
, , .
,
,

TIMED_STATISTICS TRUE. Oracle 8.0


(
7.3). -, SQL alter system set timed_statistics true, SYS. :

24

'

Oracle Server Manager Release 3.1.5.0.0-Production


(c) Copyright 1997, Oracle Corporation. All Rights Reserved,
OracleSi Enterprise Edition Release 8.1.5.0.0.-Production
With the Partitioning and Java Options
PL/SQL Release 8.1.5.0.0.-Production
SVRMGR> connect / as sysdba;
Connected.
SVRMGR> alter system set timed_statistics=true;
Statement processed.
-, Oracle
(init.ora) TRUE. Oracle
,
.

,
,
Oracle
" ".
, ,
Metalink
(tar, technical assistance request) Oracle.
.

$ORACLE_HOME Oracle
UNIX. Windows NT
%ORACLE_HOME%. , UNIX
(/),
Windows NT
(\). ,
.
utlbstat.sql utlestat.sql

, Oracle.
$ORACLE_HOME/rdbms/admin . utlbstat.sql. INTERNAL
Server Manager SQLfPlus (OracleSi ).
,
(V$). . .

25

utlestat.sql.

. ,
, report.txt. . , Server Manager
SQDTlus. , Oracle
utlbstat.sql utlestat.sql , . ,
utlbstat.sql/utlestat.sql, . , , , : report.txt.
20011031-11:15. utlbstat/estat
ran. , , Oracle,
:
Q SVRMGR> connect / as sysdba;
Connected.
SVRMGR> @$ORACLE_HOME/rdbms/admin/utlbstat
SVRMGR> Rem
SVRMGR> Rem
SVRMGR> Rem

First create all the tables

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

SVRMGR>
SVRMGR> Rem
SVRMGR> Rem
SVRMGR> Rem

Gather start statistics

SVRMGR> Rem
SVRMGR> Rem

Wait for 15 minutes

SVRMGR> @$ORACLE_HOME/rdbms/admin/utlestat
SVRMGR> Rem
SVRMGR> Rem
SVRMGR> Rem
SVRMGR>
SVRMGR> Rem

Gather Ending Statistics

26
SVRMGR> Rem
SVRMGR>Rem

Create Summary Tables

SVRMGR>
SVRMGR> Rem
SVRMGR> Rem
SVRMGR> Rem

Output Statistics

SVRMGR>

OracleSi, SQL*Plus,
connect internal connect / as sysdba.
Server Manager
Oracle9i.
OracleSi
, SQL*Plus.
report.txt : , , , .

.
. / .
, , report.txt.
web- http://www.oraperf.com/ report.txt. web-,
(YAPP, Yet Another Performance Profiling Method), , report.txt,
. , , , , . ,
, . report.txt. , ,
.
report.txt, ,
STATSPACK ( ).

27

STATSPACK ( Oracle 8.1.6 )


OracleSi (8.1.6) STATSPACK, utlbstat.sql/utlestat.sql. STATSPACK
BSTAT/ESTAT.
STATSPACK ,
BSTAT/ESTAT, , (
).

STATSPACK 8.1.6
,
Oracle 8.O.

BSTAT/ESTAT STATSPACK:
/

BSTAT/ESTAT

STATSPACK

SQL,

STATSPACK statscre.sql (spcreate.sql Oracle 8.1.7), $ORACLE_HOME/


rdbms/admin. SQI?Plus, Connect / as SYSDBA. Perfstat, .
.

SQL*Plus,
Server Manager. , ,
STATSPACK ,
BSTAT/ESTAT 15 . , ,
Perfstat
SYSTEM,
.

28

2
execute statspack.snap. , (OLTP, ..).

DBMSJOB (
UNIX). statsauto.sql (spauto.sql
Oracle 8.1.7)
:
i_snap_level 0 ,
5 SQL ( )
10
(
, Oracle Support).
i_executions_th, i_buffer_gets_th, i_disk_reads_th, i_version_count_th,
i_parse_calls_th i_sharable_mem_th ,

SQL.
i_ucomment
.
i_session_id
( ).
. statspack.modify_statspack_parameter.
statsrep.sql (spreport.sql Oracle 8.1.7).
, ,
/ .
snap_id. snap_id,
Oracle.
,
BSTAT/ESTAT. ( , ), , ,
.
,
STATSPACK , . ,
,

29

. ,
.
, , STATSPACK. , .
STATSPACK report for
DB Name
DB Id
Instance

ACME
Start Id

708513117
End Id

3
Cache Sizes

Inst Num

acme

Release

OPS

8.0.5.0.0 NO

Start Time

End Time

30-Oct-OO 13:12:15

30-Oct-OO 13:27:39

db_block_buffers:
db_block_size:
log_buffer:
shared_pool_size:
Load Profile

Host

hp6
Snap Length
(Minutes)

15.24

40000
16384
13107200
100000000

Per Second

Per Transaction

Redo size:
5739,29
2901,46

12924,49

Logical reads:
Block changes:
51,98
313,53
Physical reads:
4,71
Physical writes:
88,15
User calls:
Parses:
8,76
0,08
Hard Parses:
3,46
Sorts:
Transactions:
2,25
Rows per Sort:
691,26
1,79
Pet Blocks changed / Read:
11,13
Recursive Call Pet:
Rollback /transaction Pet:
8,54
Instance Efficiency Percentages (Target 100%)
Buffer Nowait Ratio:
Buffer Hit Ratio:

100,00
89,19

1288,43
23,08
139,23

2,09
39,14
3,89
0,04
1,54

30

2
Library Hit Ratio:
Redo NoWait Ratio:
In-memory Sort Ratio:
Soft Parse Ratio:
Latch Hit Ratio:
Top 5 Wait Events

Event

99,70
100,00
100,00
99,05
100,00

Waits

Wait
Time (cs)

7437
slave wait
1204
library cache pin
662
Parallel Query Idle Wait - Slaves
99776
db file scattered read
18386
db file sequential read
Wait Events for DB: PKMS Instance: pkms Srlaps:
->cs - centisecond - 100th of a second
->ms - millisecond - 1000th of a second (unit often used

720443
362531
121720
51846

11504
g _

% Total
Wt Time

55,3
27,8
9,35
3,98
,88

for disk 10 timings)

STATSPACK , Oracle (statspack.doc 8.1.6 spdoc.txt


8.1.7), , Oracle (Oracle Technology
Net) http://technet.oracle.com/deploy/performance/. $ORACLE_HOME/rdbms/admin.

BSTAT/ESTAT
STATSPACK, 8.0
. STATSPACK ,
BSTAT/ESTAT,

. , , Oracle
8.1.7 .
spdoc.txt.


Oracle
, report.txt STATSPACK, V$SYSTEM_EVENT, V$SESSION_EVENT V$SESSION_WAIT
Oracle.
" ". ,

,
, . "
Oracle", http://www.orapub.com/.
, , , " Oracle", . http://www.
hotsos.com/ OAUG 2000 Database SIG Meeting. ,
.

?
Oracle.
Oracle 7.0.12. Oracle 7.3 100 . 150 Oracle
8.0, Oracle 8i 200 .
: (idle) (non-idle).
idle , Oracle - .
, NULL, , pmon, rdbms ipc, smon, SQL*Net
. .
non-idle Oracle.
non-idle, " ", () , , , ,
(), ,
. .

?
,
, ,
. , ,
( "bottleneck". , .), .
V$SYSTEM_EVENT?
, ,
V$SYSTEM_EVENT. Oracle. V$SYSTEM_EVENT ( ),
, .

32

2

. V$ - .

V$SYSTEM_EVENT :
Event .
, " ",
" ", ,

" ".
Total_Waits 1
.
Total_Timeouts
.
Time_Waited ( ,
)
, .
AverageJWait ( )
,
. Average_Wait = (time_waited/total_waits).
(2 1)
( , . . .);

! drop table BEGIN_SYS_EVENT;


drop table END_SYS_EVENT;
/* Create Begin Table at Time T1 /
create table BEGIN_SYS._EVENT as
select * from V$SYSTEM_EVENT;
/* Wait n seconds or n minutes */
/* Create End Table at Time T2 */
.create table END_SYS_EVENT as
select * from V$SYSTEM_EVENT;
/* View delta numbers for wait events between Begin (T1) and End (T2) */
select T1. Event, (T2.Total_Waits-T1.Total_Waits) "Delta Waits",
(T2.Total_Timeouts-T1.Total_Timeouts) "Delta Timeouts",
(T2.Time_Waited-T1.Time_Waited) "Delta Time Waited",
(T2.Average_Wait-T1.Average_Wait) "Delta Average Wait"

33

from BEGIN_SYS_EVENT-T1, END_SYS_EVENT T2


where 1.Event = 2.Event;


.
. , / , , ?
" "?
, .
,
V$.
V$SESSION_EVENT
V$SESSION_EVENT ,
V$SYSTEM_EVENT, . ,
, SID. V$SESSION, , . V$SESSION_EVENT
,
, . ,
, .
:
Q Select S.Username, S.Program, S.Status,
SE.Event, SE.Total_Waits, SE.Total_Timeouts,
SE.Time_Waited, SE.Average_Wait
from V$SESSION S, V$SESSION_EVNT SE
where S.Sid = SE.Sid
and SE.Event not like 'SQL*Net%'
and S.Status = 'ACTIVE'
and S.Username is not null;

,
V$SESSION
NULL. ,
, PMON SMON,
. V$SESSION_EVENT
V$SYSTEM_EVENT
.

Program Name TimeOuts:

34

Q USERNAME

STATUS

EVENT

TOTAL_WAITS

UREG
AREG

ACTIVE,
ACTIVE

db file scattered read 15


latch free
12

TIME_WAITED AVERAGE_WAIT
10
27

,66666667
,44444444

V$SESSION_WAIT
V$SESSION_WAIT . , . ,
, V$SESSION_WAIT .
, .
V$SESSION_WAIT , . V$SESSION_WAIT ,
,
. ,
, , .
, ,
dbfik sequential read, , . , . ,
! V$SESSION_WAIT:
SID .
Seq#
, .
,
.
Event . :
, " ", " (
) ", ,
"
". ,
PMON Timer, RDBMS timer
. .
[1-3] ,
, .

( ) V$.
,
.

35

, db file scattered read (


), :
1 , 2 ,
, , ,
, 2. 1
V$FILESTAT DBA_DATA_FILES, a P2 - QUERY DBA_EXTENTS
SYS.UET$, , . ,
, /,
.
, " ".
2 , V$LATCH.
V$LATCH , .
Oracle.

/
, .
State
,
: wait_time seconds_in_wait.

.
, , (
() ""
"", state.
. .).
WAITING .
WAITED UNKNOWN TIME ,
TIMED_STATISTICS FALSE.
WAITED SHORT TIME ,
.
- , .
WAITED KNOWN TIME ,
, , STATE
WAITED KNOWN TIME.
Wait_time STATE
:

36

2
If STATE in ('WAITING',

'WAITED UNKNOWN TIME',

'WAITED SHORT TIME') then

WAIT_TIME = Irrelevant;
END If;
If STATE = 'WAITED KNOWN TIME' then
WAIT_TIME = Actual wait time, in seconds;

END If;

.
WAITED_SHORT_TIME, , , , .
WAITING, ,
WAIT_TIME, ,
( SECONDS_IN_WAIT). STATE WAITED.
UNKNOWNJTIME, , TIMED_ STATISTICS
TRUE .
,
, WAITING, a WAIT_TIME = Irrelevant
If. , .
Seconds_in_wait
STATE.

If STATE in ('WAITED UNKNOWN TIME', 'WAITED SHORT TIME',


TIME') then
SECONDS_IN_WAIT = Irrelevant;
END If;
If STATE = 'WAITING' then
SECONDS_IN_WAIT = Actual Wait Time in seconds;
END If;

'WAITED KNOWN

SECONDS_IN_WAIT WAITJTIME, SECONDS_IN_WAIT.


WAITED_UNKNOWN_TIME, - , TIMED_STATISTICS, . . . - WAITED_SHORT_TIME,
, , SECONDS_IN_WAIT . , , WAITED_KNOWN_TIME,
SECONDS_IN_WAIT (
WAIT_TIME), . .

,
, - .
.
, .

V$SYSTEM_EVENT:
SQL> select *
2
from V$SYSTEM_EVENT
3
where Event in (' buffer busy waits' , .
' ';;.'.
db
file
sequential
read\,
4
' 5
db file scattered read' ,
enqueue' ,
6
7
'free buffer waits' ,
8
'latch free' ,
9
log file parallel write' ,
10
log file sync' );
EVENT
TOTA'L_WAITS TOTAL_TIMEOUTS TIME_ WAITED AVERAGEJ/AIT
Latch free
enqueue
free buffer waits
buffer busy waits
log file parallel write
log file sync
db file sequential read
db file scattered read
8 rows selected.
SQL>

236563

230494

41893

424
4232
894377
3938548
1890409
62769635
17928634

40
3561
2502
0
890
0
0

343
28201
181907
804870
544425
311819246
3843986

.'

, 177090247
, 808962264
6, 66375236
,203389622
,204357037
, 287993233
4,96767658
,214404845

.. ,;:.-,'

,
,
V$SESSION_EVENT V$SESSION:
SQL> select SE.Sid, S.Username, SE.Event,
2
SE.Total_Waits, SE.Time_Waited, SE. AverageJVait
3

from V$SESSION S, V$SESSION_EVENT SE

4
5
6
7

where
and
and
and

S.Username is not null


SE.Sid = S.Sid
S.Status = 'ACTIVE'
SE.Event not like '%SQL*Net%';

38

SID

USERNAME EVENT

29
29
29
29
29
32
32
32
32
32
32
51
51
51
51
51

OLUSER14
OLUSER14
OLUSER14
OLUSER14
OLUSER14
ID2USER
ID2USER
ID2USER
ID2USER
ID2USER
ID2USER
VENDOR1
VENDOR1
VENDOR1
VENDOR1
VENDOR1

TOTAL_WAITS

TIME_WAITED

AVERAGE_WAIT

108
16
7241
1010122
6509

206
1
36357
4611646
2592
63
1
10056
10
47177
0
338
1
207155
1221
245814

1 , 90740741
,0625
5,02099158
4,56543467
,398217852
1,28571429
,111111111
1,1486008
3.33333333
,648579167
0
1,57943925
,05
3,60463902
, 395017794
, 37446872

latch free
file open
db file scattered read
db file sequential read
buffer busy waits
latch free
file open
db file sequential read
db file scattered read
log file sync
buffer busy waits
latch free
file open
db file scattered read
buffer busy waits
db file sequential read

49
9
8755
3
72739
1
214
20
57469

3091
656434

16 rows selected.
SQL>

,
, . ,
, , .
SQL> select SW.Sid, S.Username, SW.Event, SW.Wait_Time,

2
. SW.State, SW.Seconds_In_Wait SEC_IN_WAIT
3
from VSSESSION S, V$SESSION_WAIT SW
4 where S.Username is not null
5
and SW.Sid = S.Sid
6
and SW.Event not like '%SQL*Net%'
7 order by SW.WaitJTime Desc;
WAIT TIME STATE
SID USERNAME EVENT
29
OLUSER14 db file sequential read
32
ID2USER db file scattered read
51 VENDOR1 log file sync
3 rows selected.

12

SEC IN WAIT

WAITED KNOWN TIME

WAITING

WAITING

SOL>

29 dbfile sequential read.


, , . -

39

, ,
.
SQL> select Sid, Event, Pltext, P1, P2text, P2, P3text, P3
2
from V$SESSION_WAIT
3
where Sid between 28 and 52
4
and Event not like '%SQL%'
5
and Event not like '%rdbms%';
SID

EVENT

P1TEXT

29 db file sequential read file#


32 db file scattered read file
51 db file sequential read file
3 rows selected.
SQL>

P1

P2TEXT

P2

P3

67
67
63

block* 19718
block 17140
block 7556

blocks
blocks
blocks

1
32
1

. , , , . 1 .
, . 1 2,
, . .
SQL> select Owner, Segment_Name, Segment_Type, Tablespace_Name

2
3
4
Enter
old
new
Enter
old
new
OWNER

from DBA_EXTENTS
where File_Id = &FileId_In
and &BlockId_In between Block_Id and Block_Id + Bloks - 1;
value
3:
3:
value
4:
4:

for field_in: 67
where File_id = &Fileid_In
where File_id = 67
for blockid_in: 19718
and &Blockid_In between Block_Id and Block_Id + Blocks - 1
and 19718 between Block_Id and Block_Id + Blocks - 1
SEGMENT NAME

MARKET
ITEM_MASTER_INFO
1 row selected.
SQL>

SEGMENT TYPE

TABLESPACE NAME

TABLE

ITEM_MASTER

.
,

ITEM_MASTER_INFO, - . , SQL 29.



V$SQLTEXT SQL . :

40

2
GetSQLtext.sql
Simple function to access address, hash_value and return
' SQL statement (will fail if stunt size > 32 k)
CREATE OR REPLACE
FUNCTION GetSQLTxt (HashAddr_In IN V$SQLTEXT.Hash_Value%TYPE
,Addr_In IN V$SQLTEXT.Address%TYPE)
RETURN VARCHAR2
IS
Temp_SQLTxt varchar2(32767);

CURSOR SQLPiece_Cur
IS
select Piece, Sql_Text
from V$SQLTEXT
where Hash_Value = HashAddr_In
and Address = Addr_In
' order by Piece;
BEGIN
FOR SQLPiece_Rec IN SQLPiece_Cur
LOOP
Temp_SQLTxt := Temp_SQLTxt || SQLPiece_Rec.Sql_Text;
END LOOP;
RETURN Temp_SQLTxt;
END GetSQLTxt;
/
SQL,
SQL:
SQL> select Sid, GetSQLtxt(Sql_Hash_Value, Sql_Address)
2
from V$SESSION
3
where Sid = &Sid_In;
Enter value for sid_in: 29
old
2:
where S.id = &Sid_In
new 2:
where Sid = 29
SID GETSQLTXT(SQL_HASH_VALUE, SQL_ADDRESS)
29

'

select sum(decode(im.action_code,' A ' , 1,' I' ,2, ' P ' , ' V , 0 ) * im.disc_amt),
sum(im.last_amt), sum(decode(im.action_code,' A ' , 1,' I' ,2,' P ' , 1,0) * im.m
isc_amt) - sum(iffl.last_aint) from items_detail_info id, item_master_in
fo@INVP im where id.period_num in ( ' 0 0 ' , ' 0 2 ' , ' 0 4 ' ) and id.item_flg = '1'
and im.action_code in ( ' A ' , ' I ' , ' P ' ) a n d (im.suff_code_id <> 0 or im.stat
us in ( ' R ' . ' S ' ) or im.type in ( ' C ' . ' S ' ) )

SQL>
.

41

, , dbfik sequential
- , ,
, SQL.

, , ,
. . Oracle. ,
, . 2.1 ,
. 2.1 "/" .
, 2.1 , , .
2.1.
,

buffer busy waits

. ,
/ .
,
INSERT.

db file parallel write

, DBWR.
DBWR
/ DBWR.
.

db file scattered read

, .
/
/.

db file sequential read

( ) ,
. /
/.

db file single write

,
.
.

direct path read

,
/. /
.

. 281

42

2
2.1 ()

direct path write

To , . .

enqueue

,
Oracle.
, Oracle,
Oracle.

free buffer inspected

,

.

free buffer waits

.
:
, " " ( )
. ,
DBWR
/, .
,
.

latch free

( )
(latch*). ,
,
( ) init.ora.
, , .
latch free - .
,
(
),
. ,
.
, ,
OracleSi CURSOR_SHARING=force ( ).

library cache load lock

.
,
/ (
SQL, -
).

library cache lock

,
, .
,

.

43

2.1 ()

library cache pin

,
,

.

log buffer space

: LGWR
.
, (
), (),
,
.

log file parallel write

,
.
() ,
.

log file single write

.
, .

log file switch


(
)

, ARCH LGWR.
- , ,
(

, ).
ARCH
/, .

log file switch


(
)

,
( ).

log file sync

,
,
, ,
/
.

SQL*Net
/


.
,
.
ARRAYSIZE (, Oracle Forms, SQL*Plus, * . .),
ARRAYSIZE ,
, .

2.1 ()

SQL*Net
dblink

,
( SELECT ). ,
DBUNKS.
,
( )

.

sksawat

ARCH
, -
/ ( )
.

transaction

,
.

undo segment extension


. ()

MINEXTNTS .

write complete waits

, ,
.
.

, Oracle (Oracle Wait


Interface)
, ,
/.
,

Oracle. ,
,
, .
, ""
("" ), ""
,
Oracle,
.
, , ,
"".

45



,
STATE WAITED_KNOWN_TIME,
,
,
(STATE) WAITED_SHORT_TIME ( 1/100 ),

.
1/100 ,
,
- , STATE
WAITED_SHORT_TIME.


Oracle . , - , . ,
. .
.
ORACLE-00600. ,
.
.
LOG_CHECKPOINTS_TO_ALERT = TRUE
.
,
, .
, ,
, , Oracle.
: '

''

'


( ),
. .
:
alter session set timed_statistics=true; /* If not already set */
alter session set max_dump_file_size=unlimited; /* Just to make sure your trace
file does not get truncated, due to current setting in database */

46

2
alter session set events '10046 trace name context forever, level x';
/* Where X = (1,4,8,12) */
1
= Statistics
4
= Statistics, Bind Variable Values
8
= Statistics, Wait Event Information
12
= Statistics, Bind Variable Values, Wait Event Information
1. ,
USER_DUMP_DEST.
2. , WAIT.
, - :
1. ID (SPID, session process ID).
ID
, :
select S.Username, P.Spid
frora V$SESSION S, V$PROCESS P
where. S.PADDR = P'.ADDR
and S.Username like 'A%";
2. SQDTlus svrmgrl
internal (connect as internal) (connect /as sysdba):
alter system set timed_statistics=true; /* If not already set */
alter system set max_dump_file_size=unlimited; /* Just to make sure your
trace file does not get truncated, due to current setting in the
database */
oradebug setospid <SPID>
oradebug unlimit
oradebug event 10046 trace name context forever, level X /* Where X =
(1,4,8,16) */
3.
.
4. , SPID,
USER_DUMP_DEST.
5. , WAIT.

,
. UNIX Windows NT,

47

,
.

,
Oracle Windows NT.
, ,
UNIX, ,
Windows NT,
UNIX.
Windows NT,
/ UNIX.
, UNIX
-
. ,

Windows NT.
Windows NT
Windows NT
, Windows NT (Start | Programs Administrative Tools (Common) | Performance Monitor).
, Edit
| Add to Chart, . , , , ,
UNIX.
Windows NT. Windows NT Task Manager (

, , ).
, , ,

Windows NT, web- Syslnternals Inc. :
http:///www.sysinternals.com/. Windows NT.
UNIX
UNIX ,
.
UNIX, .
sar, vmstat, iostat, cpustat, mpstat, netstat,
top osview. ,

UNIX, UNIX
( a.k.a).

Sun Solaris ( 2.61).
,
PerfMon Glance Plus, - . , ,
, , ,
. . Oracle, .
UNIX
sar -u 5 1000. ir system activity reporter ( ).
- . ( ), .
:
' .
:
? , ,
, , (2
).

(2 )

,
UNIX.
,
.

, , 100 . , vmstat sar -q
. Windows NT Task Manager Performance, Processor Object . ,
: % , % % , , -

49

(DPC Queued per


second) . . sar -u:
Q SunOS ganymede 5.7 Generic sun4u 10/30/00
%usr
18:58:12
%sys
%wio
18:58:17
68
4
22
18:58:22
61
2
22
18:58:27
57
11
4
18:58:32
46
5
23
18:58:37
67
2
10
67
18:58:42
4
20
18:58:47
73
3
15
18:58:52
75
4
5
79
18:58:57
4
18
18:59:02
69
3
12
66
Average
4
16

%idle
4
15
28
27
21
9
9
16
0
17
14

: %usr, %sys,
%wio %idle. %usr , (
, " "
). Oracle . %sys ,
( ,
/ , , , ,
. .). %wio , , /
. /
, (
/),
- .
/, , - .
%wio ,
. , , %idle
, , , .
%sys %wio 1015%. , , ,

50

1
(%sys),
/ (%wio). , . 99 100 .
sar -d 5 1000.
, ,
(avque), (r+w/s), (blks/s 512- ),
/ 5- (avwait )
, / (avserv). , Windows NT Logical Disk
Object.
,
(%busy) 60%. ,

,
(avque, avwait avserv). ( ) avserv 100
.
, .

,

, .
, , , ,

sar -d, . ,
,
/ , ,
, .
Oracle.

,
, ,
.

.
sar -d:

51

Q SunOS ganymede 5.7 Generic sun4u 10/30/00


19:09:51
device %busy avque r+w/s.
19:09:56
dadl
30
0,5
59
dadl.d
21
0,2
21
dad1,f
18
0,2
34
19:10:01

dadl
dadl.d
dad1,f

25
22
14

0,4
0,2
0,1

46
23
16

19:10:06

dadl
dadl.d
dad1,f

28
22
18

0,5
0,2
0,2

50
15
29

Average

dadl
dadl.d

29
23

0,5
0,3

61
30

dad1,f

15

0,2

25


, vmstat -S 5 1000. ,
, . -S
, , (S swap. . .),
, .
6 : , , , ( )
, / , . Windows NT .
vmstat -S:
procs

1
0
2
3
2

b
0
0
0
0
0

w
0
0
0
0
0

memory
swap free

page
si so pi

po
1864 168 0 0 124 72
1906800 10808 0 0 0 0
1906800 10800 0 0 0 0
1907288 11112 0 0 0 0
1907288 11112 0 0 0 0

disk

fr de sr dd
93 0 11 2
0 0 0 0
0 0 0 1
0 0 0 0
0 0 0 0

dd
17
2
2
2
2

faults

fO
0
0
0
0
0

sO
0
0
0
0
0

in
sy
cs
471 554 1208
191 13616 201
172 13671 175
174 13584 170
172 13630 164

opu
us sy
23 9
98 2
96 4
96 4
97 3

id
68
0
0
0
0

b w , swap free
, si so pi po fr de sr (

52

2
), dd dd fO sO , in sy cs /
, a us sy id ( sar -u ,
%wio %idle ). 2.2
vmstat -S.

2.2.

Vmstat -S
Vmstat -S (
)

( w)

,
( ).
b , - ,
/, . .
w , ,
(, -
).

(swap free)

swap ( ),
.
free ( ).

(si so
pi po fr de sr)

si so ,
.
pi
.
fr .
de .
sr ( ),
.

(dd dd fO sO)

.
/ .
, sar -d.

(in sy cs)

in .
sy .
cs .

CPU (us sy id)

us ,
.
sy ,
.
id ,
( /).

53

:
() () , (si so),
, (de)
(sr). , ,
. b ( /) , si so (
0, SGA
Oracle PGA), de sr , , ^ .
(, Solaris 2.8) sr
. Solaris sr, .
, , top osview
, "" . sar , -
( -), , ( -q) . . , sar,
UNIX, vmstat . ,
sar -q 5 1000 runq-sz . ,
( ), ,
. (swpq-sz swpocc), , .
netstat -v netstat -s , .
. Windows NT
, .
, ( ) .
"" . , ,
. , , , .

54

-, . ,
, , .
,
, SHARED_POOL_SIZE.
DB_BLOCK_BUFFERS .
,
10 10 ,
, . SQL, ,
. SQL .
, .
Oracle, , , . Oracle,
, ; Oracle Metalink
Oracle Technology Network (OTN), , . - ,
.
, - . , , "" , /.
,
, .
, , ,
Oracle. , , . , V$ , ,
, . , . %wio
sar -d 5 1000 , (
)? , .

,
SQL. , , . ,
.

55

, , , , , , .
, ,
. , . ,
.
, , ,
, truncate , .



. , . , , , -
, , .
, , ? , : ? ?
, . , .

3 7 ,

, .
, ,
.
, . , , ,
(
. . .), .

. (, - ) ,
. ,
,

56

2
.
, , ,
. ,
.
, ,
.

60


SQL,
/,
, .

, SQL ,
, , . , , ,
,
. , , , , , ,
, .
/,
, , .
,
,
( ,
15%). /. / .
.
( ,
" " ),
.

., , .
(
) . ,
.
. ,
.


, 80%

Oracle?
, , SQL, SQL .
-
/, , .
,
. : SQL .
, - ,
, : "
?" " " (,
?) . . ,
. ,
!
, SQL. ,
..., , ! ,
, "" .
PL/SQL, .
, ,
, , ,
,
SQL, .
, ( , , .) . , , , , , .
- SQL (
- " ". - . .)
. !
. ,
!

SQL

62

3
.
, SQL.
.
( ), (
, Oracle) . , 80%
SQL. - ?
. , SQL, ,
. SQL, , , .
,
(,
): 1. Eyal Aronoff, Kevin Loney. Advanced Oracle Tuning and
Administration. 2. Guy Harrison. Oracle SQL High Performance Tuning. 3. Peter Corrigan,
Mark Gurry. Oracle Performance Tuning.
, , , ,
SQL. , , - . :
-
SQL. , , .

SQL
.
.

Oracle
SQL, , SQL. Oracle,
SQL.

63

: ,

, 7.0, Oracle SQL. , . ,


, , , , .
:
1 ROWID .
, where
(ROWID). ,
(). ,
OracleS,
ROWID. !
8 (,
).

"-,

9 .
15 .
, ", ". , SQL, , ,
15, , . ( where), ( ), 8 9.
, 8 9 , 15 ( , , 15),
,
,

SQL. , , : ,
SQL, , .
, ? " ", , . , SQL
-

64

3
. ,
( ) , . , ,
, . , ( )
(OLTP,
online transaction processing). , ,
, . .

,
?
: . , where SQL -
( M/jjber(Last_name), round(price) . .),
.
, :
select Last_Name, Hire_Date, Salary
from EMP
where Mgr_Id = 123;
( Mgr_Id Mgr_Id_Idx). Co , 123
, , , ( MGR_Id_Idx).
, , , , ,
, .
LJ select Last_Name, Hire_Date, Salary
from EMP
where round(Mgr_Id) = 123;
SQL , ,

SQL, .
, SQL "" , "-

J55

".
SQL.
( " - "). ,
SQL ' , .

, ,
:
Oracle .
, , .
, , ,
, ,
Oracle. , , ,
, , , ,
SQL. : "
, , ". ,
!
, :
J\ 8 ,
where ( ).
9 AND-EQUALS (
).
10 , ,
where ( ,
).
9 10, , , . , , Oracle Apps,
,
:
Q select Code_Combination_Id
from GL_CODE_COMBINATIONS

66

3
where Segment1=:v1
and Segment2=:v2
and Segment3=:v3
and Segment4=:v4
and Segment5=:v5;

, , : glcc_nl(Segments, Segmentl, Segment2, Segment4, Segments) ./* Good */.


, , . /,
.
, Code_Combination_Id ( ), ,
AND- EQUALS ( 9), ,

: glcc_nl(Segments, Segmentl, Segments, Segment4, Segments,
Code_Combination_Id) /* Bad */. , ( , ,
9), ( , ,
10).

Oracle 7.0 , . , 1990-. ,


. , , ,
SQL.
, . ,
, , ,
, , .
. , , , SQL Oracle
- , . .
, .
SQL. , .

67

( Oracle
7.0 - 7.2) . , , . ? ,
, 100000 , Color.
,
, ,
,
.
( , )
, 100 Color.
, SQL , , (100000/100) = 1000 .
, , . , .

: ,

.
. , ,
. ,
( )
, . : , ,
, (, ,
).

, - . . , .
Oracle Rdb 1996-1997 . ,
Rdb . , , Rdb

68

3
Oracle, , Oracle
7.3 Oracle .
.
, . .


Oracle 7.3 ( , ).
, ' . , ,
.


SQL,
, .
Oracle 8.1.6,
CURSOR_SHARING.
OracleSi FORCE,
.
. .
, DML, . .
. , " " , . ( ,
.)


Oracle
, Oracle
- ,
OPTIMIZER_MODE. (
init.ora) CHOOSE, . . RULE

69

. - ALL_ROWS
FIRST_ROWS,
,
.

FIRST_ROWS ALL_ROWS,
OPTIMIZER_MODE /*+hint*/
. ,
OPTIMIZER_MODE :
[ SQbPlus: Release 8.1.5.0.0 - Production on Fri Nov 3 16:04:31 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8.1.5,0.0 - Production
With the Partitioning and Java options
PL/SOL Release 8.1.5.0.0 - Production
SQL> alter session set OPTIMIZER_MODE=FIRST_ROWS /* Modifying OPTIMIZER_MODE
just for this session */;
Session altered.

""?
, "", . , , , ( , ,
)? , , , (, , ). -
: ", " ", , ,
". , . , Oracle, (. . )
, .
, Oracle,
SQL /*+hint*/. , ( + /*) . ,
SQL, Oracle
. , SQL .
, SQL
(/*+hint*/):

70

Q SQL*Plus: Release 8.1.5.0.0 - Production on Fri Nov 3 16:04:31 2000.


(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
select /*+ FIRST_ROWS */ Last_Name, Hire_0ate, Salary
from EMP
where Mgr_id = 123;

, ,
, , -
, -
. ,
,
.
,
,
SQL. ,

.

,
SQL. " OracleSi"
Oracle ( ), Oracle. OracleSi,
Oracle.

?
OPTIMIZER_MODE CHOOSE, , , , .
SQL
, . , , OPTIMIZER_MODE
(/*+ hint */) .

71

,

.
, ( , , , ).
, , ,
select, SQL
,
, .
, .
. (. . ,
), , . , num_rows USER_TABLES. - ,
. .
, ( , , - ,
).
,
. , .

,
,
Last_Analyzed
DBA_TAB_COI_UMNS .
DISTINCT,

.

72


,
. , , , , ,
.

, ,
. , SQL Oracle
.

, analyze. ,
, .
: - , .
,
, .


SYS,

. ,
,
SYS.
OracleSi ,
analyze, DBMS_STATS. , ( ),
.
-

73

. .

.

DBMS_STATS
Oracle
Application. Oracle Apps
, DBMS_STATS
, , Application Object
Library Schema.
OracleSi SQL
, . . ,
, , . .
Oracle , , .
DBMS_STATS Stored Outlines ( ) ,
.
" OracleSi" Oracle.

?
, , , . ^
.
,

. - , , .
.
20% .
, . . ,
, . , 4 . 281

, 100%(
. ,
, , , , ,
.
, ,
, , . . ,
OracleSi, DBMS_STATS , .

, analyze
estimate , 49%,
compute.

, (
)
sample estimate
, ,
. sample
.

Q analyze table LINE_ITEMS


compute statistics /* This calculation computes full
statistics for the LINEJTEMS table and all of its indexes */;

analyze table LINE_ITEMS


compute statistics
for all indexed columns size 254 /* This calculation computes histograms
for all columns of all indexes on the LINE_ITEMS table.
The Size 254 is for the number of buckets utilized during the calculation
of the distribution of data */;

analyze table LINE_ITEMS

75

estimate statistics
sample size 20 percent /* This calculation estimates statistics for the
LINE_ITEMS table and all of its indexes using a sample size of 20 percent
of the number of rows in the table */;

analyze
.
analyze_schema DBMS_UTILITY
.
BENCHMARK estimate, 20%. \ :
Q SQL*Plus: Release 8 . 1 . 5 . 0 . 0 - Production on Fri Nov 3 16:07:33 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8 . 1 . 5 . 0 . 0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
SQL> execute dbmsjjtility.analyze_schema('BENCHMARK' ,\
'estimate', estimate_percent=>20);
- PL/SQL procedure successfully completed,
DBMS_STATS, OracleSi,
.
, ,
BENCHMARK, 20%
.
, gather_schema_statistics false. true,
. , ,
. ,
, () () gather_index_stats.
, ,
.
Q SQL*Plus: Release 8.1.5.0.0. - Production on Fri Nov 3 16:08:12 2000

76

3
() Copyright 1999 Oracle Corporation, All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
SQL> execute dbms_stats.gather_schema_statistics('BENCHMARK' ,\
20, estimate_percent=>20);
-PL/SQL procedure successfully completed.

gather_schema_statistics .
export_schema_stats,
. ,

( )
,
.
import_schema_stats
. ,
export_schema_stats
import_schema_stats.
,
( , )
. ,

gather_schema_stats gather_database_stats.

, SQL SQL, analyze


BENCHMARK , . , SYS SQL*Plus.
, OracleSi
, .
" "
"
". , !
, ,
STATISTICS NONE,
.
ESTIMATE,
Oracle 1064 .
' , ,

77

stajtistics=none
,

.
,
. ,
. , rebuild
, (. . )
, ,
.

, estimate compute rebuild (,
, ). ,
, ,
analyze.

,
.
Oracle (7.3.x, 8.0.4, 8.0.5 .) estimate
. ,
estimate
,
.
,
(, )
,

.
, :
,
, .
.
/* Set up environment for script file generation */
set echo off

set feedback off


set verify off
set pagesize 0
spool analyze_script.sql
/* Run query for script file generation */
select 'analyze table' || Owner || '.' || Tablejiame || 'estimate
statistics sample size 20 percent;'
from DBA_TABLES

where Owner in ('BENCHMARK')

78

3
and Table_Name like 'A%';
spool off

/* Run query script file to calculate statistics on all tables based


on a sample size of 20 percent */
@analyze_script. sql
set echo on
set feedback on
set verify on
set pagesize 23
* '
.t

. .
( ) , , .
. ,
- , - . ,
. ,
. 10 , , 5 , ,
.
DBMS_STATS

automatic. ,
monitoring . , , (alter), monitoring yes.
dbms_stats.gather_schema_stats dbms_stats.gather_
database_stats. ,
"" () .
,
DML. , " Oracle". , ,
, . -

79

, ,
( ,
). Oracle. , , , , ,
.
.

,

Oracle analyze
. Oracle ( Oracle 7.2 ), ,
, .
.
, ,
, , .
,

analyze. ,
, , . ,
, /.
-


,
, .
, .

, . .
, , ROWID , .

3
, Oracle ,
*-. ,
.
, , - . () , .
()
ROWID, .
,
. , ,
.
SQL , , , , , ,
. ,
*- ,
, *-
, .

?
, /, ,
/, , .
, , , 1 , 5 . ,
4 . , .
, , , , 80%
. , , ROWID, ,
. , .
, , " " ( )
,
. 1 , 1 100 . -

,
, 100% ,
, / ,
. ,
/ /
.



"Predicting the Utility of the Nonunique Index" Gary Millsap, Craig Shallahamer, M. Adler (OracleMagazine, Spring 1993,
pp. 48-53). . , ,
, , ,
. , , , , .
. ,
.
, ,
, . .

- ,
. , .

LINEJTEMS? , ,
. ,
, .
, ,
.
() :

82

,

:
1. /
?
: , ,
.
2.
?
: . ,
V$SQLAREA V$SQLTEXT
SQL. V$SQLAREA ,
( executions),
, where
.
3. ,
?
:
, ,
. ,
, ,
.
4. , where,
?

83

: ,
/ null.
.

.
5. , ,
?
/
: ,

.

?
,
, ,
() ()
INDX.
6. ,
( )
(
)?
: , .
,
.
7.
?
:

, .

8. (
, ), ,
..?
:
.
9.
?
:

, ,

84

3

. ?
10. ,
? (
OracleSi,
, , , .)
: ,
Oracle,
, .
$*-
,
. ?
?
, ,
, .

OracleS,
()
100%, 50, .
,
.

,
/,
.
, , . .
: , , , , .
: (
ROWID) .
1 2.


,
Ord_Id, Ord_Status Ord_Date, , . , Ord_Status Ord_Date
.

85

SQL, Ord_Id where . , , :


Q create index U_ORD_ID_STATUS_DATE on ORDERS
( Ord_Id,Ord_Date,Ord_Status)
tablespace INDX;


OracleSi.
upper, lower, roundm. . , .
OracleSi . :
Q create index UJ)RD_ID_STATUS_DATE ON ORDERS
( upper(Ord_Id),Ord_Date, Ord_Status)
tablespace INOX;
,
PL/SQL.
PL/SQL calc_profit
Q create index LINE_ITEM_CALC_PROFIT on LINE_ITEMS
(Calc_Profit(Item_Id, Item_Cost, Sticker_Price))
tablespace INDX;
line_item_calc_frrofit LINE_ITEMS, $1000 :
Q select Ord_Id, ItemJEd, Item_Cost, Sticker_Price
from Line_Items
where Calc_Profit(Item_Id, Item_Cost, Sticker_Price) > 1000;

?
*-, ,
, / ( / ).
,
. , / . , , ,

86

3
,
.
, ? , ? ,
.
, "" .
, , , .
, 1
10 , 1000/10=100 .
1200, 20 , 1200/20=60 . ,
20%- , 40%- . , .
, , INDEX_STATS. analyze index
index_name validate structure. , . , INDEX_STATS Height (),
, 1 ( ).
,
. ,
.

analyze index index_name validate


structure INDEX_STATS
,
.
, .
,
. , ,
, Oracle 7.3.0,
Oracle 8.1.7.
, (, ,
OracleSi, ) .

87

, . , , .
, ALTER index...
rebuild parallel. , unrecoverable ( , Oracle 8.0)
nologging ( Oracle 8.0 ). ,

init.ora , (. " ".
Q alter index U_ORD_ID_STATUS_DATE rebuild
parallel (degree 4)
nologging

tablespace INDX
/* You can use the ONLINE clause for the above statement if your
database version is OracleSi or above */;


.

parallel
.
() ()
,
, ,
() ()
.
,
coalesce alter index. / , . ,
,
() .
. ,

/ , . , .


.
. ,
SQL. Oracle 7.3, . -,
- .
. , , , SQL .
- . , , .
, . - , . ,
where ,
.
- , . ,
. , .
Pascal . , - .
- OLTP .
, ,
"" ,
. , ,
, - . !
.
Oracle

89

, - ( ),
. Oracle - , ,
. ,
. ( ) Oracle , - . ,
, .
Oracle 7.3. , HASH_AREA_SIZE HASH_MULTIBLOCK_IO_COUNT.
- ,
where . Oracle /,
.
: , /, Oracle
.
hash_area_size, .


HASH_AREA_SIZE HASH_MULTIBLOCK_IO_COUNT
, Oracle
.


(. " -
").

, . , ,
/.
SQL.

SQL
-
. -

90

SQL,

. . (,
) , , . "" SQL, . .
, where
SQL
, .
,
(, + 0
(") - ),
SQL FULL (
).
, :
1. LINEJLTEMS 1 .
2. Shipped_Date
.
3. Shipped_Date ,
.
4. .
:
select *
from LINE_ITEMS
where Shipped_Date between SYSDATE
and (SYSDATE - 30);

Shipped_Date, , . , , FULL
( ), ,
, LINEJTEMS, PARALLEL
(
init.ora). :
:
select /* + FULL(LINE_ITEMS) PARALLEL(LINE_ITEMS, 2) */ *
from LINE_ITEMS

where Shipped_Date between SYSDATE


and (SYSOATE - 30);

i , where
SQL
,
( ,
).
(
). ,
INDEX , .
,
, ,
,
. :
1. ORDERS 1 .
2. Ord_Id -
( ),
. Ord_Id
, .
3. Ord_Id, Ord_Status
Ord_Date.
4. .
:
select *
from ORDERS
where upper(Ord_Id) = ' : '
and Ord_Status = 'Not Filled'
and Ord_0ate = SYSDATE;
, upper. ':'
. ,
. :
:

select *
from ORDERS
where Ord_Id = upper ( ' : ' )
and Ord_Status = 'Not Filled'
and Ord^Date = SYSDATE;

(,'.-,-:

92

3
Ord_Id - , , OracleSi, , . , OracleSi,
- : , initcap (,
, - ). ,
, - .
.
, .
, number,

where. , ,
- ,
, varchar2(10)
.
. ,
where ,

.
null ,
.
, SQL,
,
where. ,
SQL.
where
SQL .
SQL

.
,
.
:
select First_Name, Last_Name, Hire_Date
from EMP
where Empno = 1234;
select First_Name, Last_Name, Hire_Date
from EMP
where Empno = 9876;

93

:
select First_Name, Last_Name, Hire_Date
from EMP
where Empno = :;

, , - OracleSi (8.1.6).
init.ora
CURSOR_SHARING=f<rrce.
SQL, . CURSOR_SHARING . ,
CURSOR_SHARING= force , -
.
PL/SQL
insert, update delete
.

PL/SQL. ,
insert
, ,
/*+APPEND*/,
.
, delete update,
,
, ,
,
. :
:
declare
Ord_Struct ORDERS%ROWTYPE;
Cursor c_ord is
select *
from ORDERS
where Ord_Status = 'Not Filled'
and Ord_Date = SYSDATE;
begin
open c_ord;
loop
fetch c_ord into Ord_Struct;
exit when c_ord%NOTFOUNO;
insert into TEMP_ORD values (Ord_Struct.Ord_Id, Ord_Struct.Ord_Date,

94

3
(Ord._Struct.Ord_Price * 1.1), Ord_Stnjct.Ord_Status);
commit;
end loop;
close c_ord;
end;
/
PL/SQL

.
TEMP_ORD 10%. ,
. ,
/*+APPEND*/ .
, TEMP_ORD nologging . alter table. , , Oracle
.
, - TEMP_ORD . ,
, - ,
. , , commit , .
:
declare
begin
insert A+APPEND*/ into TEMPJ5RD
select Ord_Id, Ord_Date, (Ord_Price * 1.1), Ord_Status
from ORDERS
where Ord_Status = 'Not Filled'
and Ord_Date = SYSDATE;
commit;
end;
/
He ,
,
,
.

95

, ,
.
( from
select, 7.3),
.
,
, . ,
!
:
select OUTER. *
from EMP OUTER
where OUTER.Salary >
(select Avg(Salary)
from EMP INNER
where INNER.Dept_Id = OUTER.Dept_Id);

, . .
, . ,
,
,
, , .

,
.
:
select E1.*
from EMP E1, (select E2.Dept_Id Oept_Id, Avg(E2.Salary) Avg_Sal
from EMP E2
group by Dept_Id) DEPT_AVG_SAL
where E1.Dept_Id = DEPT_AVG_SAL.Dept_Id
and E1.Salary > DEPT_AVG_SAL.Avg_Sal;

,
. where
select,
, from. ,
(
, , . - . .)
.

3
, , SQL,
,
.

, .
, . ,
SQL, PL/SQL .
.
:
1 ,
12 .
. decode (
if., then..else..end / SQL)
insert, update.
decode ,
' greater than
less than. (+),

. ,
, -
insert, .
,
update
insert.
SQL

.
create table,
:
create table DM_SUMMARY_TBL
( Fact_Id

,D2_Key
,D1_Key
,Datekey
, D2_Col
,D1_Col1
,D1_Col2,

parallel (degree 12)


nologging
partition by range(datekey)
(P1 values less than...P36 values less than NOMAXVALUE)
as

97

select /*+ FULL(F) FULL(D1) FULL(D2) */


F.Fact_Id,
F.D2_Key,
F.D1_Key,
F.Datekey,
D2.D2_Col,
D1.D1_Col1,
D1.D1_Col2
from FACT F, DIMENSION D1, DIMENSION D2
where D1.D1_key(+) = F.D1_Key
and F.D2_key = 02.D2_Key(+);

He , SQL
.
SQL
,
, ,
. , , select
where ,
(, 1 ), (1 ). where
,
,
.

, SQL
, ,
Oracle
, , 99,999%,
.
select from DUAL
, . ,
.
,
,
select (nextval)
PL/SQL
values insert. values
insert nextval
(sequence_name.nextval).
,
( ).
. DUAL.

98

3
:
declare
Ord_Seq_Val ORDERS.Ord_Id%TYPE;
begin
for i in 1. .10000
loop
select Ord_Seq.NEXTVAL
into Ord_Seq_Val
from DUAL;
insert into TEMP_ORD(Ord_Id)
values (Ord_Seq_Val);
/* Do more misc. processing */
end loop;
/
:
'declare
begin
for i in 1. .10000
loop
insert into TEMP_ORD(Ord_Id)
values (Ord_Seq_Val.NEXTVAL);
/* Do more misc. processing */
end loop;
/
, (
, ),
/ SQL
(, ).
,
, , , ,
- , .

(ERP), . !

SQL

'

, , , , , ,
, SQL.
: , /.

99

.
SQL, SQL.
, ,
. ,
, ?
.
SQL ,
, , , . ,
, , , / , .
, , .

SQL


SQL. , . :
/
, .
,
, , ,
, .
SQL , .
,
.
, ,
.
,
.
where SQL not exist not in.
substr like .
(, like 'A%')
, . substr
, , ,
OracleSi .
, , nvl,
, ,
, ,
(typecasting). ,

100

3
,
90-, ,
, -
(
NVL).
OR
union all. ,

. " ".
. ,
.
.
1,00,
.
,
,
.
,

- (master- detail).
( ).
.
,
/, , ,
.

unique. OracleSi
.
, ,
. ,
. , primary key
Ord_Id ORDERS,
,
, Ord_Id .
enable no/validate
,
. ,
,
,
.
, where
,
or, and not
.

101


DML -
rowid (
, ).

( ),
,
,
.
,

.
SQL .
, Oracle
,
SQL, .

.
,
,
,
.
.

. Oracle ( )

.
, . .
()
, .
,
.
,
where .
.

, .
, PL/SQL. ,
PL/SQL.
Productjd (
OracleSi bulk collect), 20%
ReorderJLevel PRODUCTS.

102

__
/

3
.

-
.
declare
TYPE Ord_Id_Tab IS TABLE OF PRODUCTS. Product_IdTYPE;
begin
/* Retrieve all values of Product_Id that are relevant */
select /+ FULL (PRODUCTS) */ Product_Id BULK COLLECT into
Product_Id_Tab;
from PRODUCTS
where Product_Name like 'A%";
forall i in 1. .Product_Id_Tab.LAST
update PRODUCTS
set REORDER_LEVEL = (REORDER_LEVEL * 0.8)
where Product_Id = Product_Id_Tab(i);
/* Do more processing */

end;


,

, PL/SQL.

OracleSi,
SQL ( DBMS_SQL) ,
PL/SQL execute immediate,
, DBMS_SQL.
PL/SQL, execute immediate
Ord_Id ORDERS
8 ( ) 10 . ,
PL/SQL DDL,
,
:
declare
begin
execute immediate 'alter table ORDERS modify (Ord_Id VARCHAR(IO))' ;
end;


. .
,

103

/
,
SGA Oracle.

.
,
( ), from
,
.
,
,
sort_area_size,
.
, :
. ,
,
. ,
, . ,
.

.


from ,
/*+ ORDERED */.

from. ,

where. ,
, .




SQL
53.281

SQL

107

? , , ,
-
.

SQL
-

106


,
, SQL.

t -

, , ,
, . , , SQL,
. 16 SQL, , .
- , . , , .
, .

J 1- , ! .
SQL, - , , ,
. , SQL,
, , mai tais - . , ! , ,
, . . ,
, , - . : - , 1
/, 1 , , /, . ? -

108

, ,
, ,

. (
) ,

. ,

SQL

107

? , , ,
-
.

SQL
SQL:
1. , 11_81818 TRUE
( init.ora
, alter system).
2. , MAX_DUMP_FILE_SIZE
.
.
3. USER_DUMP_DEST ,
.
.
4.
SQL_TRACE.
5. .
6. .
7. (tkpwf, transient kernel
profile)
8. .
9. "" SQL.
10. 4 9 ,
.
-

SQL?
SQL . ,
, .

108

, ,
, ,

. (
) ,

. ,
,
.
?
?
? ,
(. .
) init.ora
. Oracle MTS,
, (
SQL) ,
.
SQL . SQL_TRACE .
SQL, ( ) Oracle:
USER_DUMP_DEST = <$ORACLE_ADMIN>/<$ORACLE _SID>/udump
OFA . ,
. ,
, .
TIMED_STATISTICS = TRUE
init.ora,
Oracle - , . , ,
Oracle - , . TIMED_STATISTICS , alter system alter session
, .
,
TIMED_STATISTICS init.ora.
MAX_DUMP_FILE_SIZE = 1024

SQL

109


. , , alter session
UNLIMITED, .

SQL_TRACE = TRUE init.ora,


SQL.
, ,
,
USER_DUMP_DEST,
.
( ) init.ora FALSE.
TRUE
, ,
TRUE
.

, :
Q SQL*Plus: Release 8 . 1 . 5 . 0 . 0 - Production on Fri Nov 10 20:57:18 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8 . 1 . 5 . 0 . 0 - Production
With the Partitioning and Java options
PL/SQL Release 8 . 1 . 5 . 0 . 0 - Production
SQL> alter session set timed_statistics=true /* Optional - Only if
setting at the instance level permanently causes problems */;
Session altered.
SQL> alter session sql_trace=true;
Session altered.
SQL> /Execute your SQL statements */
SQL> alter session set timed_statistics=false /* Only if it were set
to true in the current session */;
Session altered.
SQL> alter session set sql_trace=false;
Session altered.

Oracle 7.2 .
, SQLJTRACE
, SQL.
Oracle 7.2

110

.
, SQL_TRACE FALSE
. , "" .
, , .
, - . ,
, ,
SQL_TRACE. ,
, ,
. , TIMED_
STATISTICS TRUE :
SQL*Plus: Release 8.1.5.0.0 - Production on Fri Nov 10 21:10:38 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:

OracleSi Enterprise Edition Release 8.1.5.0.0 - Production


With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
SQL> select Sid, Serial
2
from VSSESSION
3
where Username = 'BENCHMARK' /* Determine the SID, SERIAL of the
session that you are trying to trace from v$session /;

SID

SERIAL*

11

54

SQL> execute dbms_system.set_sql_trace_in_session('11', '54',TRUE);


PL/SQL procedure successfully completed.
SQL> /* Wait for SQL statements to execute for a certain period */
SQL> execute dbms_system.set_sql_trace_in_session('11', '54',FALSE);
PL/SQL procedure successfully completed.
.



, ,

(. ",
").

SQL

111


?
, ,
,
Oracle USER_DUMP_DEST. ,
, :
Q SQL-Plus: Release 8 . 1 . 5 . 0 . 0 - Production on Fri Nov 10 21:19:41 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
OracleSi Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
SQL> select Value
2
from V$PARAMETER
3 where Name = 'user_dump_dest' /* Determine the destination of
USER_DUMP_DEST */l
VALUE
/u01/app/oracle/admin/prod815/udump

<$ORACLE_SID>_ora_<ID ID - Spid V$SESSION.


ID , ST001:
Q select S.Username, P.Spid, S.Program
from V$SESSION S, V$PROCESS P
where S.PADDR = P.ADDR
and S.Username = 'STOOV;
, , ID / ( , , ), ,
UNDC, . ( ), ,
Oracle. ,
, host. .
,
Windows NT.

112

SQL>! /* Host out of SQL*Plus, Do not exit */


$ps
/* Determine the processes within your current shell. This is
to determine the process ID of your SQL*Plus session */
1262 pts/2 0:00 tcsh
1279 pts/2 0:03 sqlplus
1327 pts/2 0:00 ksh
$ps -ef | grep 1279 /* Now scan all processes on the system and filter out the
ones with your SQL*Plus's process ID. This is to determine the process ID of
the server process that this SOL*Plus
session is attached to */
oracle 1280 1279 0 21:41:00 ?
0:12 oracleprod815
(DESCRIPTION^ LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 1279 1262 0 2.1:40:59 pts/2
0:03 sqlplus
oracle 1327 1279 0 22:38:57 pts/2
0:00 /bin/ksh
\
$cd /u01/app/oracle/admin/prod815/udump /* Change directory to the
USER_DUMP_DEST directory */
$ls -It | grep 1280
total 816
-rw-ree
1 oracle dba

408548 Nov 10 21:04 prod815_ora_1280.trc

tkprof
SQL - tkprof, , Oracle.
tkprof, , . :
Q C:\tkprof

Usage: tkprof tracefile outputfile [explain= ] [table= ]


[print= ] [insert= ] [sys= ] [sort= ]
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements.
aggregate=yes|no
insert=filename List SQL statements and data inside INSERT statements.
sys=no
TKPROF does not list SQL statements run as user SYS.
record=filename Record non-recursive statements found in the trace file,

SQL
sort=option
prscnt
prscpu
prsela
prsdsk
prsqry
prscu
prsmis
execnt
execpu
exeela
exedsk
exeqry
execu
exerow
exemis
fchcnt
fchcpu
fchela
fchdsk
fchqry
fchcu
fchrow
userid

113

Set of zero or more of the following sort options:


number of times parse was called
cpu time parsing
elapsed time parsing
number of disk reads during parse
number of buffers for consistent read during parse
number .of buffers for current read during parse
number of misses in library cache during parse
number of execute was called
cpu time spent executing
elapsed time executing
number of disk reads during execute
number of buffers for consistent read during execute
number of buffers for current read during execute
number of rows processed during execute
number of library cache misses during execute
number of times fetch was called
cpu time spent fetching
elapsed time fetching
number of disk reads during fetch
number of buffers for consistent read during fetch
number of buffers for current read during fetch
number of rows fetched
userid of user that parsed the cursor

, , , sort=<opti> .
fchela-, . ,
.
, , , userid, Explain Plan tkprof,
PLAN_TABLE .
tkprof utlxplan.sql, $ORACLE_HOME/rdbms/ admin.
tkprof,
, prod815_ora_1280.trc.
ifejbro/ output.prf, benchmark benchmark, -

114

SQL SYS
" ".
$tkprof rod815__1280.trc output.prf explain=benchmark/benchmark sys=no
sort=fchdsk

prsela, exeela fchela,


- , SQL. fchela,
SQL .
select ,
fchela select.
SQL, (INSERT,
UPDATE DELETE), exeela .
, ,
sort=(prsela,exeela,fchela). /
( /, Oracle ),
sort=(prsdsk,exedsk,fchdsk).
/ ( /,
Oracle ) , sort=(prsqry,prscu,exeqry,execu,fchqry,fchcu). ,
/ , / , , - .
/ , , / (
) .

tkprof
,

oracle. tkprof
(
oracle),
init.ora _TRACE_FILES_PUBLIC=TRUE,

.

SQL

115

tkprof
tkprof . :
Q select A.Id, A.Name, .Name
from AUTHOR A, BOOK
where A.Author_Id = .Book_Author_Id
and A.AuthorJEd = 101
order by B.Name;
call
count
cpu
elapsed

Parse
Execute
Fetch
Totals

1
1
27
29

0,02
0,01
0,24
0,27

0,02
0,01
0,36
0,39

disk

query

current

rows

0
0
1230
1230

0
0
2342
2342

0
0
0
0

0
0
399
399

tkprof:
Call SQL ( define bind
Parse).
Count

/ .

CPU CPU .
Elapsed ( ) ,
,
, /,
. .
Disk Oracle, (
/) .
Query Oracle,
.
Current Oracle, .
Rows , .
select Fetch insert/'update
.
, Query Current. / .

116

(Query Current), / SQL.


" - ,
", SQL . ,
/, - . /,
(SQL). , , . ,

, . , SQL,
, , .
- SQL 1 / , 100 , .
- .
/ (SQL).
, /,
, , , ,
( Oracle) / .
, , ,
, .
,
. , . , .
SQL, ,
.

Oracle - ?
() Oracle Oracle. , , - SQL. Explain Plan
, , : ?
Oracle.

SQL

117

Oracle?

(, ) explain=userid/password tkprof. , Explain Plan SQL,


, , Oracle
SQL , .
Explain Plan
SQL ( SQL SQL DDL, ). , tkprof
,
PLANJTABLE .
Explain Plan:
Q select A.Id, A.Name, B.Name
from AUTHOR A, BOOK

where A.Author_Id = B.Book_Author_Id


and A.Author_Id = 101
order by B.Name;
Query Plan

1.0 SELECT STATEMENT Statement Cost = 148


2.1 SORT ORDER BY (7th)
3.1 FILTER (6th)
4.1 NESTED LOOPS (5th)
5.1 TABLE ACCESS BY ROWID AUTHOR (2nd)
6.1 INDEX UNIQUE SCAN AUTHORJtd UNIQUE (1st)
5.2 TABLE ACCESS BY ROWID BOOK (4th)
6.2 INDEX RANGE SCAN BOOK_AUTH_ID NON-UNIQUE (3rd)
- SQL Explain Plan:
Q explain plan for
select A.Id, A.Name, B.Name
from AUTHOR A, BOOK
where A.Author_Id = B.Book_Author_Id
and A.Author_Id = 101
order by B.Name;
Explain Plan
Plan_TABLE:
Q select IpadC ', 2*(Level -1))| [Operation]!' ' I I
decode(Id, 0, 'Cost = '| (position) "Operation"", Options, Object_Name
from PLANTABLE
start with Id = 0
connect by prior Id = Parent_Id
order by Id;

118

() PLAN_TABLE,

(
).

, -
?

explain plan , , () .
- 6.1, AUTHOR_ID AUTHOR. 6.1 - 5.1.
, 5 - " ",
- 5.2. 5.2 6.2, : RANGE SCAN
BOOK_AUTH_ID (, ) BOOK. 6.2 5.2.
"" 5 , 5.1
5.2 4.1 (
). 4.1 3.1 ,
( 101). 3.1
2.1, ORDER BY,
(1.0) , .

Cost=X,
.
/,
SQL. ,
100%- , Cost= 1000000 -
(, ,
), Cost=4567.
. , ,
SQL , , Cost=4500,
,
Cost=4567. ,
SQL
. ,
, SQL
/*+HINT*/, .

SQL

119

AUTOTRACE?
AUTOTRACE - , ,
SQI?Plus. SQI?Plus 2.3, , SQL_TRACE,
tkprof, ,
, , . AUTOTRACE
, .
AUTOTRACE plustrce.sql, $ORACLE_HOME/sqlplus/admin. Oracle,
8.1.0 Windows NT,
plusXX. plustrce.sql ( )
$ORACLE_HOME/dbms.
AUTOTRACE,
SYS, . PLUSTRACE. ,
,
PLUSTRACE AUTOTRACE.

AUTOTRACE Explain Plan


SQL
, PLANJTABLE
AUTOTRACE.
, AUTOTRACE
utlxplan.sql,
$ORACLE_HOME/rdbms/admin.
AUTOTRACE set autotrace on, , , . traceonly
, .

traceonly
Explain Plan SQL.
, AUTOTRACE
SQL*Plus Windows,
"Query is Executing",
Cancel Explain Plan.

120

4
AUTOTRACE:

SQL> set autotrace traceonly


SQL> select count (*) from TEST_OBJECTS;
Execution Plan
0
1
2

0
1

SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1)


SORT (AGGREGATE)
TABLE ACCESS (FULL) OF 'TEST_OBJECTS' (Cost=1 Card=1)

Statistics
28 recursive calls 16 db block gets
2 consistent gets
0 physical reads
0 redo size
1083 bytes sent via SQL*Net to client
669 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1
0
1

sorts (memory)
sorts (disk)
rows processed

, AUTOTRACE
, , / SQL, /,
( ),
SQL, (
) .

,

SQL .
, 24 100
SQL 2
, /, 1
/
,
. ,
1 % , 50%
. ,
V$SQL Buffer Gets Executions.

3Jv> I

GD

124


( 99%)
(
). , .

: ,
? -
? ,
. , (
)
. , ,

() . Oracle /, " ".
,
. -
, : ,
, . , Oracle (. . )
. ,
. , , ,
,
. ,
SQL (, , ).
, Oracle,
(RMAN, Recovery Manager),
(Parallel Query), Java Oracle (MTS, Oracle
multithreaded server). , , , :
SQL
.

125

! , Oracle, " "


( - " " " ". - .
.). , - .
- " ", .
,
, 100% , . : , ( ), , Java ,
. ( ,
!) .
, , , , Oracle9i
. , OracleQi ,
. !
- ( : SPA - Shared
Pool Area ( ),
. - . .). ,
, , , .
:
. !
, Oracle. ,
, ,
. :
. ,
( : - . - .
.). , -
.
, ,
. (SGA, System Global
Area). SPA . Oracle 7.3. OracleS
.
, , .

126

,
, , ,
, , . , , , ,
. , , " - , " " -
SQL". , , ,
Oracle .
, ( ), Oracle
, SQL. , . ,
Oracle. ,
, , . .

Oracle
, ,
, . Oracle. Oracle, , .
,
. . 5.1 Oracle .
, .

, Oracle.
.

(SGA),

.
.

127

, .
Oracle.

, .
,
, ,
Oracle .

(SGA)
,
Oracle. ,
,
, Oracle
. , ,
SQL,
.

SGA,
SQL,
.

,
.

, Oracle 7.3
. ,
SQL ( , ).

Java

OracleS .
, RMAN,
MTS.
.
OracleSi .
Java
.
SGA,
,
.


- SGA Oracle,
, . Oracle, . SGA

128

Oracle

. 5.1.

Oracle, Oracle

129

. V$SGA:
*

SVRMGR> startup
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.

122838416 bytes
" 64912 bytes
55484416 bytes
67108864 bytes
180224 bytes

Database opened.
SVRMGR> select sum(Value)
2>
from VifcSGA;
SUM(VALUE)
122838416
1 row selected.
SVRMGR>

SGA SPA,
( ) . Oracle 7.3 . ,
OracleS SGA Java.
(init.ora).
init.ora.
SGA, Oracle
OracleSi.

(SPA)
SPA SHARED_POOL_SIZE.
SPA (LC, Library Cache), (DDC, Data Dictionary Cache) (
). , 1,
, . , . LC
SQL, ,
. DDC
, , ..,
SQL. ,
DDC " ".

130


Oracle . : , , , / .

.
,
.
Oracle , ( " ")
( ) . ,
- (committed) .
, ,
, . Oracle ,
( , - ,
).
" ".
DB_BLOCK_BUFFERS. ,
, DB_BLOCK_SIZE, DB_BLOCK_
BUFFERS. 10 8 ,
81920000 78 .


LOGJBUFFER ,
, .
, DML.
Oracle, , (. " - ").


Oracle 7.3 , SQL PL/SQL (, ). ' ,
SQL SQL ( SQL) , , SQL .
SHARED_POOL_RESERVED_SIZE,

131
.

SQL , .


OracleS (
).
MTS RMAN.
LARGE_POOL_SIZE.

Java
OracleSi. JAVA_POOL_SIZE Java ,
SQL. , Java
, , Oracle . , , , 100 .
.

8.1.6 show sga


V$SGASTAT ,
Java, .

SGA, Oracle,
, ,
, - , . (UNIX) (Windows NT).
. .
, , , . .
. 5.1 .
( Oracle), , , .

. . .

132

SMON

SGA
,
. SMON ( ,
OPTIMAL)
( ).

PMON

Oracle ( ).
. , ,
,
. .

DBWR DBW*

. ,
.
, ( )
SQL*Loader SORT_DIRECT_WRITES TRUE.
(, ,
.)
.
.

LGWR

.
.
.

RECO

,
. ,
. ,
DELINKS. ,
DISTRIBUTED JRANSACTIONS
.


, LGWR.
OracleS , .

LGWR DBWR.
Oracle
. , , /, ,
. , , ,
.
DBWR , , ( TRUE SORT_DIRECT_WRITES) , :

133

.
,
( ).

(LRU,least of recently used blocks)
,
.
.
LGWR
, :
( DBWR).
. ,
,
, .
,
, . ,
131072 ,
43690
. OracleS,
,
MIN(1 , LOG_BUFFER/3).
.
DBWR
(. ).
, ? ,
. , ,
.
/ (
/).

DBWR "" ,
, LGWR
, DBWR,
, ,
, .


.
, , ,
.

134

:
OracleS,
" " / .
, , .

. . Oracle ( )
, . , SQI?Plus
, .
,
Oracle MTS.
Oracle MTS,
( ), SQL .
, SQL ( ) .
, ,
,
.
( / Oracle)
. , ,
- ( SQL). (
), ,
, . ,
, ,
.
UNIX, Oracle. (SQIfPlus).
i

SQL*Plus ,
.
SQL*Plus
(telnet) -,
Oracle.

135

Q oracle 15956
oracle 15958
oracle 15960
oracle 15962
oracle 15964
oracle 15966
oracle 16032
oracle 16033
(DESCRIPTION

1
1
1
1
1
1
15939
16032

0
0
0
0
0
0
0
1

11 :23
11 :23
11 23
11 23
11 23
11 23
14 10
14: 10

9
9
9
9
?

pts/1
9

00 :00 01
00 :00 :00
00 :00 :00
00 :00 00
00 :00 06
00 :00 00
00 :00 01
00 00 02

ora_pmon_oradev
ora_dbwO_oradev
ora_lgwr_oradev
ora_ckpt_oradev
ora_smon_oradev
ora_reco_orade,v
sqlplus
oracleoradev

, , ,
? , , , ,
.
, DBWR
, ,
. , , LGWR
. , , , . ()
Oracle , ",
", . , SGA Oracle -
. , ,
, , , . Oracle , .

(PGA, Program Global Area)


. 5.1 PGA, ,
(Professional Golfers Association). Oracle. PGA,
-
, : ,
. (
, , Oracle MTS, PGA ).
, , . (, , , 1
. .). -

136

, ID ( ), ( )
( ).

SQL:
ENTER?
, Oracle SQL PL/SQL, . SQL
( , SQL select ):
(Parse), (Define), (Bind), (Execute)
(Fetch). ,
select . , .
SQL

SQL,

SQL
SQL


,
, SQL
SQL*Net Net8/Net8i.

(:, :vt),
SQL

,
( insert, update delete)
.
.
, ""
.

select
,

( ).


ASCII . , -

137

.
, ,
SQL.
, ,
,
. , ... , - . , , . ,
, . . .
- SQL, , SQL
.

SQL.
( ) .
SQI?Net Net8/Net8i.
, ( ) Windows NT ( ASCII), , , IBM, Oracle MVS (
EBCDIC). , long, short, word, double
. .
.
SQL " SQL" . SQL.
.
,
, . SQL - insert, updatevuin
delete, . , . . , ,
( ) ( ).
select. ,
. SQL.
. 281

138

,
SQL -,
SQL. , . .
,
, , . , , .
, SQL,
- ( alter, analyze . .),
INVALID. , SQL, . , analyze SQL ,
, .
?
1
5 , , , analyze , .
, Oracle ,
analyze?
',
SQL, ?
, . , SQL
DDL, .
.
(
), . , ,
, , SQL select.
, , ,
. , , . : ,
. , ?

139

, SQL

,
-.
,
- ( , -
).

:
SQL? , ,
,
, , , . ,
.
.
,
, , -, SQL . , ,
.


, . ,
, Java RMAN. ,
, Parallel Query MTS.
Oracle

SHARED_POOL_SIZE

SHARED_POOL_RESERVED_SIZE


- .

SHARED_POOL_RESERVED_MIN_AI10C

. ,
Oracle 8.O.3.

140

8
Oracle

LARGE POOL SIZE

OracleSi

.
Oracle MTS,
PGA: -
- -.
.

LARGE POOL WIN ALLOC


. ,
Oracle 8.O.3.

PARALLEL AUTOMATIC TUNING


.
LARGE_POOL_SIZE
15 , .
, OracleSi.

JAVA POOL SIZE

Java
.
.

SESSION CACHED CURSORS


, ,


.
,
.
.


7.3 Oracle? . Oracle 7.3,
SQL . OracleS - ,
OracleSi - Java ( Java).
, - . , , Oracle MTS Oracle?,
. / , ,
- . ( ) .

141

- init.ora . ,
. ,
, . . ,
.

,
. SHARED_POOL_SIZE,
SHARED_POOL_RESERVED_SIZE LARGE_POOL_SIZE.
. ,
. , , . Oracle MTS, Parallel Query,
RMAN. . , SHARED_POOL_SIZE
128 , a LARGE_POOL_SIZE - 32 , 32 SHARED_POOL_SIZE 128 .
SHARED_POOL_RESERVED_MIN_ALLOC , 8.0.3 . 8.0.3,
(_). , Oracle.


LARGE_POOL_SIZE init.ora. . Oracle 8.0.3 LARGE_POOL_MIN_ALLOC ,
. 8.0.3 , ,
init.ora _LARGE_POOL_MIN_ALLOC, .
, Oracle
MTS RMAN . Oracle MTS, Cursor State
User Session Data PGA . , , -

142

.
.

,
, Oracle,
MTS, PGA
, .
Oracle 8.1.6.
RMAN , , . ,
,
, . OracleSi PARALLEL_AUTOMATIC_TUNING TRUE
,
LARGE_POOL_SIZE .

15-20%
. , V$SGASTAT , "large pool memory in use".
"large pool free memory", , , . ,
. , SGA, , ,
.
, .

Java
Java JAVA_POOL_SIZE.
, . ?
Oracle , 100 . ,
, . JAVA_POOL_SIZ,E
1 , Java .

143

SPA
init.ora,
,
, . , , . ,
, , :


ORA-4031 ( )
Oracle MTS
Java
RMAN

, '
. - ,
.



Oracle.
( )
SQL
(

select * from dual;).

.
,
90%- . :
, 5
.
, ,
, .
-, . V$SGASTAT , ,
. V$SGASTAT , -

144

.
SVRMGR> select Pool, sum(Bytes)
2>
from V$SGASTAT
3> where pool = 'shared pool'
4> group by pool;
POOL
SUM(BYTES)
shared pool
55464348
1 row selected.

SVRMGR> select Pool,Bytes


2>

3>
POOL

from V$SGASTAT

where Name = 'free memory"


BYTES

shared pool
large pool
2 rows selected.

23338928
14367854

" "
. ,

. ,
" " (,
), ,
.


( VSSGASTAT
).
Oracle
. ,

V$SHARED_POOL_RESERVED (
Oracle)
Request_Misses, ,
.

( , ) ,

145


SHARED_POOL_SIZE. , , SHARED_POOL_RESERVED_SIZE, LARGE_POOL_SIZE JAVA.
POOL_SIZE
.


SQL . , " "
. , . , ,
,
, .

,

.
CURSOR_SHARING=FORCE ( OracleSi
), ,

.
SVRMGR> select Namespace, Gethitratio, Pinhitratio
2>

from V$LIBRARYCACHE;

NAMESPACE

SQL AREA
TABLE/PROCEDURE
BODY
TRIGGER
INDEX
CLUSTER
OBJECT
PIPE

GETHITRATIO

, 868686869
,784251969
,75
1.
0
,963768116
1
1

PINHITRATIO

,916376307
,745541023
,75
1
0
,97382199
1
1

8 rows selected.
SVRMGR>
GETS PINS?
GETHITRATIO PINHITRATIO. GETS
,
PINS - .

8
GETHITRATTO
, .
"SQL AREA", , Oracle .

. , - .
, ,
. !
- V$SQLAREA where, SQL .
( , ) ,
, .
. .
SQL .
SQL , 8.1.6 , CURSOR_SHARING
FORCE. Oracle
.
, , , V$SYSSTAT V$SYSSTAT .
OracleSi (8.1.6.1):
Q SVRMGR> select A.Value total,
2>
.Value hard,
3>
A.Value-B.Value soft,
4>
round((B,Value/A.Value)lOO.1) hardparseperc
5>

from V$SYSSTAT A, V$SYSSTAT B, V$SYSSTAT

6>
, 7>

where A.Statistic^ = 171


and B.Statistictf = 172;

TOTAL

HARD

536

149

1 row selected.
SVRMGR>

SOFT

387

HARDPARSEPERC

27,8

147

Oracle 8.1.6.1 ,
V$SYSSTAT ,
STATSTIC* ()
(),
.

Oracle?
,
V$.
,
.
tkprof .
tkprof "Misses in library
cache during parse" .
, SQL . , ,
. ,
,
,
RELOADS PINS. ,
, , ,
. ,
, ,
, , . (reloads) (, ).
Q SVRMGR> select sum(Reloads)/sum(Pins)
2>

from VSLIBRARYCACHE;

SUM(RELOADS)/SUM(PINS)
,001234873

- . , 1%, .
SQL PL/SQL.
, SQL,

148

. ( ) .
SQL PL/SQL ,
. , "" :
Q SVRMGR> select Name, Sharablejnem
2>
from V$DB_OBJECT_CACHE
3>
where type in ('PACKAGE', 'PACKAGE BODY',
4>
, 'PROCEDURE');
NAME
DBMS_APPLICATION_INFO
DBMS_APPLICATION_INFO
DBMS_STANDARD
STANDARD
DBMS_OUTPUT
DBMS_OUTPUT

'FUNCTION'
SHARABLE MEM
12873
2709
15809
218332
14155
6419

6 rows selected.
SVRMGR>

- standard.
. ,
, SHARED_POOL_RESERVED_SIZE 15-20% . SHARED_POOL_RESERVED_MIN_
ALLOC , , .

SHARED_POOL_RESERVED_MIN_ALLOC
Oracle, 8.0.3,
_SHARED_POOL_RESERVED_MIN_ALLOC.

Oracle.
, .
, , ,
. , -

149

- , .
V$SQLAREA, Sharable_Mem SQL. .

,
SQL. ( ), . SQL
SQL. Oracle SQL , . /.
, , , :
Q SVRMGR> .select to_char(
2>
round((1-sum(Getmisses)/sum(Gets)))*100 l
3>
1)) || %', "Hit Ratio"
4>
from V$ROWCACHE;
Hit Ratio
89,8%

1 row selected.
SVRMGR>
Ha
( 90%). .


Oracle DBMS_SHARED_POOL,
. keep, , .
, dbmspool.sql, $ORACLE_HOME
/rdbms/admin.
Q SQL> exec dbms_shared_pool.keepCSTANDARD');
PL/SQL procedure successfully completed.

8
Oracle . , , .
, .
-
, .
,
. - ,
unkeep
DBMS,SHAEED_POOL.
, , Kept V$DB_OBJECT_CACHE:
SVRMGR> select Owner, Name, Type, Sharable_mem, Kept
2>
3>

from V$DB_OBJECT_CACHE
where Type in

4>

5>

('FUNCTION',

'PACKAGE',

'PACKAGE B O D Y ' ,

'PROCEDURE')

OWNE

order by Owner, Name;


NAME

TYPE

SYS
SYS
SYS
SYS

DBMS_APPLICATION_INFO
DBMS_APPLICATION_INFO
STANDARD
STANDARD

PACKAGE BODY
PACKAGE
PACKAGE BODY

SHARABLE MEM

KEP

12873
2865
218604
28576

NO
NO
YES
YES

PACKAGE

4 rows selected.
SVRMGR>

, ( SQL).
, V$SQLAREA
ADDRESS HASH_VALUE, keep.
Q SQL> exec dbms_shared_pool.keepC21589568,4139960791', ' ' ) ;
PL/SQL procedure successfully completed.

DBMS_
SHARED_POOL desc .
. , ""
.
. , , STANDARD, DBMS_DESCRIBE, DBMS_
APPLICATIONJNFO, DBMS_STANDARD, DBMS_OUTPUT DBMS_UTILITY.

151

SYS,
.

Oracle 8.1.6
( ), ,

" ", . . ,
keep.
unkeep.

:
ORA-04031
, SQL,
- . ORA04031 - , Oracle
, . Oracle .
! , , .
,
.
i
,
DBMS_SHARED_POOL
,
,
init.ora
SHARED_POOL_RESERVED_SIZE SHARED_POOL_SIZE.
, INIT.ORA
LARGE_POOL_SIZE.
, . ,
. .

. :

152

(
)
_/
V$SGASTAT
( )
(KEPT)
SQL ,

Oracle 8.1.6 CURSOR_SHARING,
,

, ,
(KEPT) ,
(
SESSION_CACHED_CURSORS)
PL/SQL
(Oracle 7.3
) (Oracle 8.0
)
.

, . , Oracle .
(LRU, least recently
used) .
Oracle .
" , ", , . ,
, .
( , : -
" ". - , .),
. Oracle
, ,
.
, ,
( ), . , ,
. ---, .

153


ORA-04031: "unable to allocate %s bytes of shared memory".

ORA-04031 Oracle 7.3



, ORA-04031, Oracle 7.3 . ,
.
Oracle 7.3, %s , "%s
". , ORA-04031.
Oracle 7.3 %s
, .
Oracle 8.0, SQL, ,
MTS,
PGA, . .
Oracle 7.3 Parallel Query , 8.0
RMAN.
Oracle 8.0 LARGE_POOL_SIZE. , ,
MTS/PARALLEL Query/RMAN , , , ,
ORA-04031. , SQL .
, ,
( - , 4050 . . , .) , . SHARED_POOL_RESERVED_
SIZE SHARED_POOL_RESERVED_MIN_ALLOC, LARGE.
POOLjSIZE. , . ,
(dbms_shared_pool.keep) .
, .

154

,

,
, ,
. ,
V$SESSION_WAIT (latch free),
, , . .
Select SW.Sid, S.Username, substr(SW.Event, 1,
from V$SESSION S, V$SESSION_WAIT SW

35),

SW.Wait_time

where SW.Event not like 'SQL*Net%'


and SW.Sid = S.Sid
order by SW.Wait_time, SW.Event;

, .
,
, ( ) , , , ( ,
, Java). , SQL
-
.
, .
Oracle.
latch free

latch*, .
, ,
. , .
latch free . ,
latch*
( , ),
.
, SQL
. ,
, OracleSi
CURSOR_SHARING=FORCE, .

library cache load lock

, .
, /
(
SQL,
).

155

library cache lock

,
.
,
.

library cache pin

,
.

V.

158


60% , .

! ,
, . (CHR, cache-hit ratio) OLTP, . ,
,
, CHR. ,
, , , . CHR. , ,
CHR 60%. - ,
, ,
.

, 99%
, , .

. SQL,
( ),
CHR . ,
Oracle ,
. , , LRU , , CHR
99%. , . , CHR ( 99%) SQL
. " " ""
SQL, .

159

_ , , - -
Oracle.
, . "
", .
- , Oracle.
. , .
Oracle, ,
.
. Oracle 99% (
).
6 . , .
, , ,
, .
, Oracle SQL.
CHR 98%, Oracle , Oracle , . ,
SQL, ,
45 , " " . , .

" " ( " SQL"
" - , " , ), SQL 45 , 65% . ,
, . , , , CHR 72%,
, , .
,
.
, Oracle, .

160

:
, , , , , , .
- ,
. CHR ,
, , .
, , CHR , .
/


, , ?

,
. Oracle
. , (
Oracle)
. , . ( )
, (MMU, memory management
unit) .
MMU, .
Oracle, , , " ",
Oracle. Transaction Processing: Techniques and Concepts. Gray, Reuter
:
= (( 1 - 1
) * )/ 1 '
, / 1997 ., ,
.
, ( ) 8-10 ,
1997 . . Oracle ,
(, , . .), 10
, .

161
/

" " ,
. , ,
10 , ,
. /.
, Oracle /.
. , , , Oracle .
,
. :
.
, .


-, (
), (, , ).
-, Oracle , , . , ,
. , , .
, , . -, ,
, , , , .


OracleSi

, Oracle, OracleSi,
. () (
). , ,
,
" , " (FIFO, first-in-first-out).
(LRU, Least Recently Used).

162

, LRU . .
,
, -
- , .
, - .
,
. -
"-" . ,
, . ,
" ". ,
, .
, , . LRU . ,
, .
Oracle FIFO
LRU .
, , LRU LRU (, ,
).
, , ,
" " . , (
). LRU,
. ,
, ,
.
.
LRU, ,
. , . , Oracle () ,
. (DBWR, database writer)
, . , /,
/. -

163

,
. DBWR
, () LRU (
). , ().
LRLJ Oracle 7.3, . ,
, 1 5. , . (-) (1-5) . 1- , - 2-, - 3-, D 4-, - 5-. F ( ),
? LRU
(MRU. most recently used)
, F . 1, 2, 3,4, 5
:
1 =

2 =

3 =

4 = D

5 =

1,
, , , (, , . . .). , 1 (
). 1
, , . , LRU , :
1 = F

2 =

3 =

4 = D

5 =

, , ,
, . . -
,
, . , , ,
( ). ,
, - .
,
/ . , ; , , LRU
, . ,

164

Oracle LRU,
.
cache, (
MRU) .
/. , MRU- , cache,
Oracle.


Oracled!

, OracleSi , LRU. .

, "" . , "" LRU
. LRU. ,
""
. , "".
, .
? ,
. , , , . , ,
.
, - , ( ). ,
, .
, , . LRU, LRU,
. , "" .
,
, , ( , , ,
). ,
: , .

165

, , , , .

, ,
OracleS,
" ",
, ,
OracleSi.



, : DB_BLOCK_SIZE
DB_BLOCK_BUFFERS. DB_BLOCK_BUFFERS
, . . ,
DB_BLOCK_S1ZE. . ,
DB_BLOCK_SIZE = 8192, a DB_BLOCK_BUFFERS = 10000, 81920000 , 80 . , ,
.
:
Q SVRMGR> startup
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.

48572320
64912
45137920
2048000
73728

bytes
bytes
bytes
bytes
bytes

, Oracle , SQL PL/SQL


, ,

. OracleS ,
, PL/SQL . .
, , , .

166

Oracle 7.3 LRU , LRU.


>

, , .
.
DB_BLOCK_BUFFERS - ,
, . :
Q DB_BIOCK_BUFFERS = 10000
,
, .
LRU, DB_BLOCK_LRU_LATCHES.
.
LRU , , LRU. , ,
. Oracle
:
Q DB_BLOCK_LRU_LATCHES = 16 /*This is for an 8-CPU machine '*/


, , .
, . , ,
. , , , , ,
. BUFFER_POOL_KEEP (
DB_BLOCK_BUFFERS).
LRU DB_BLOCK_LRU_LATCHES:
Q BUFFER_POOL_KEEP = (buffers:2000, lru_latches:2)
, ,
-

167

, DB_BLOCK_BUFFERS. ,
DB_BLOCK_LRU_LATCHES.


. BUFFER_POOL_
RECYCLE -
:

BUFFER_POOL_RECYCLE = (buffers: 1000, lru_latches:1)


1
10 ( , DB_BLOCK_
BUFFERS) LRU,
. . , , , ,
(, -, . - . .). ,
. ""
.
( )
.

, . , (
) ,
. ,
, tkprof, , V$CACHE V$BH.

,
.
, ,
(DB_BLOCK_BUFFERS(BUFFER_POOL_KEEP+BUFFER_POOL_RECYCLE)).
,
50 .

V$BUFFER_POOL ,
.

168

,
V$CACHE V$BH, , ,
( ) ,
catparr.sql,
$ORACLE_HOME/rdbms/admin.


. :

Q create table EMP (Empid number,


Lname varchar2(30),
Fname varchar2(30),
Salary number(8,2))
tablespace EMP_DATA01
storage (buffer_pool keep);
keep. buffer_poolue , .
buffer_pool storage alter.

cache

,
Oracle . , OracleS. ,
. cache , . ,

LRU (, OracleSi). , . ,
, . , cachene , ,
/ . - .
cache . , alter table EMP cache;
.

169


(MRU) LRU. ,
. , . ,
cache keep.


,
: ; , , ; ,
.
report.txt, STATSPACK V$SYSTEM_EVENT
V$SESSION_EVENT. , , /. , -
.


" " - ,
. ,
-.
, ,
Oracle

. ,
. ,
. ( , Oracle
),
. consistent get db block get V$SYSSTAT report.txt.
CHR. , .
CHR = 100* (1 - (physical reads / (consistent gets + db dlock
"*
gets - physical reads))
.281

170

6
V$SYSSTAT :

Q consistent gets = 47229


db block gets = 2148
physical reads = 3923
CHR,
Qj CHR = 100 * (1- (3923/(47229+2148-3923))) = 91,37%
CHR . 14:00 , ,
.' , . , 14:00,
, 2:00, , . ,
, , .

,
, ,

.
,
( V$)
()
.
-
.
, .
V$BUFFER_POOL_$TATISTICS.
$ORACLE_HOME/rdbms/admin/catperf.sql (
). , CHR. V$BUFFER_
POOL_STATISTICS:

select Physical_Reads, DB_Block_Gets, Consistent_Gets


from V$BUFFER_POOL_STATISTICS
where Name = 'KEEP';

171

,
KEEP RECYCLE.
.
, .
. , , ,
.
, . , 100%,
, , , . , , ,
" " . ,
, , CHR . CHR .

?
, , -, , .
,
/. :
select 0.Owner, O.Object_Type, O.Object_Name, count(B.Ob]d)
from V$BH B, DBA_OBJECTS 0
where B.Objd = 0.Object_Id
group by 0.Owner, O.Object_Type, O.Object_Name
having count(B.Objd) > (select to_number(Value*.05)
from V$PARAMETER
where Name = 'db_block_buffers');
, 5% . 5 , .
, 5%- :
Q OWNER
DSTG
SYS
SYS
SYS

OBJECT_TYPE

OBJECT_NAME

INDEX
CLUSTER
INDEX
TABLE

COMPANY_STATUS_PK
C_OBJ
I_OBJAUTH1
OBJAUTHS

COUNT(B.ODJD)

245
440
206
185

172

, .

,

CHR ,
, . ,
V$SESSION_WAIT buffer busy waits free buffer
waits. latch free , cache buffers chains
cache buffers Iru chain. , , /, CHR
.
Q select SW.Sid, S.Username, substr(SW.Event,. 1, 35), SW.Wait_Time
from V$SESSION S, V$SESSION_WAIT SW
where SW.Event not like 'SQL*Net%'
and SW.Sid = S.Sid
order by SW.Wait_Time, SW. Event;

,
.
,
. , , , ,
. , SQL /

. () ,
. /, . Oracle.
buffer busy waits

. ,
/ .
,
.
,
.

db file sequential read

, .
/
/.

173

db file scattered read

, .
/
/.

free buffers waits

.
: ,
( )
.
, free buffer inspected
.

latch free

latch*,
. ,

init.ora.
, .
: - , . latch
free .



,
( ):

.
DB_BLOCK_BUFFERS ,
, ,


. ,
,
,
DB_BLOCK_BUFFERS .

.

.
, ,
.
.
,
.
initrans ufreelists,
.

174


DB_BLOCK_BUFFERS, ,
,
, .

.
( ,
),
keep,
. ,
,
,
.
LRU
, ,
. ,
,
.
cache ,
.
, /, . /
. : / .

,

.
, ( ). ,
/.
, /. ,
, / - .
DB_BLOCK_SIZE

.
,
.

175

DB BLOCK BUFFERS

SGA.
, Oracle
,
, /.


().

DB BLOCK LRU LATCHES

, LRU
.

- . ,
,
, .

BUFER POOL KEEP

/
DB_BLOCK_BUFERS DB_BLOCK_LRU_LATCHES .
,
.

.

BUFER POOL RECYCLE

BUFFER_POOL_RECYCLE
DB_BLOCK_BUFERS DB_BLOCKLRU_LATCHES
. ^
/.

/ ,

(. " /").

178


, .
1 - , 8 .

, ,
. , . busy
. ,
, . , ,
. , LOG_BUFFER . ,
, ,
. , :
- !

SQL
( ), ,
.

SQL , , - ,
OracleS, . OracleS , (
, *-> )
,
. OracleS , ,
Oracle .
, ,
, .

179

, , ,
. , , . : ,
(DBWR), (LGWR,
log writer), (ARCH) . , ,
SQL. ,
Oracle. " " ( , ; Oracle. - . .) ,
.



.
SGA. ,
Oracle LOG_BUFFER.
,
. ( ) ( )
, (ID) .
LGWR .
, arcivelog , ARCH . LGWR
- . ,
,
. , - , (-
).
- , , (
- , - , ,
. -. .). , ,

180

f
. ?
. -
- ,
, . , . ,
( ) .
,
- LGWR . , !
DML, , () .
, ( , Oracle
), , LGWR . . ,
Oracle 7.3:
1. ,
. , Oracle
.
2. , ,
,
, .
3. ,

(),
.
. , ,
Oracle
LOG_SIMULTANEOUS_COPIES. OracleSi
(
). , Oracle 7.3.x,
.
Oracle 7.3.4
.

.

181

4.
.

.
,
,

.
5.
, . (

Oracle
.)
6. .
7.
,
, .
,
(commit) (rollback).
,
.
8. , ,
( ,
), ()
.

, ,

. , ,
,
. ,
'


, . .
. ,
,
, .
SGA !
- !

LGWR :

182

7
( DBWR). , OracleS,
.
. ,
,
,
.
,
. ,
131072 , LGWR
,
43690 .
OracleS, LGWR ,
MIN(lMB,LOG_BUFFER/3).
, ,
Oracle
.

. ,
, .
, , ,
, LGWR . ,
,
,
. OracleS
1
( ,
3 ) .
,
15 , LGWR ,
1
. ,
,
---. ,
LGWR,
. !
.
DBWR.
,
,
.


"Redo log buffers" :

SVRMGR> startup
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo log buffers
Database mounted.
Database opened.

48572320
64912
45137920
2048000
524288

183

bytes
bytes
bytes
bytes
bytes_

, V$PARAMETER:

select Name, Value


from V$PARAMETER
' where Name = 'log_buffer';
NAME
VALUE
log_buffer

524288

. . Oracle 8.0 73728 (72 ). Oracle


8.1.5 524288 (512 ).
, . ,
LOG_BUFFER = 131072 (128 ).
. ,
(. , " , "). ,
32 , ,
. , .

, . "
".
LOG_BUFFER

,
. 131072
.

184

IjOG SIMULTANEOUS COPIES

.
.
, OracleSi
( _LOG_SIMULTANEOUS_COPIES), ,
, ,
. ,
,
.

,

,
.
, . , , () ()
. , .
log buffer space

- LGWR

.

,
.

log file parallel write

,
. , (
) ,
.

log file single write

.
.

log file switch (archiving


needed)

, ARCH LGWR.
- , ,

( , ,
, ).

ARCH /

Oracle ( ).

185

log file switch (checkpoint


incomplete)


( /
). ,

. ,
,
.

log file sync


.
,
,
/ .

latch free

latch*.
,
initora.
, ,
. : , .
latch free .


(LOG_SIMULTANEOUS_COPIES), OracleSi.

,

, ,
. :
,
. log buffer ,
, . log file (. ),
, , , /.
latch free log
buffer ,
. V$LATCH redo copy latch redo allocation
latch, . ,
. (misses)
(gets) immediates_misses immediate_gets 1%,
LOG_SIMULTANEOUS_COPIES (, OracleSi), .

186

. , OracleSi
.
, , , -,
, , ,
.
, ,
.
,
, V$SESSION_WAIT.


/

,
,
.
,
. .
,
.
,

. ,
-
. , . .
,
.
(
) .
LOG_BUFFER .
128 256 , .
, , 1 , , , - . , .
( ) .

187


Oracle.
Oracle, ,
. ( . - . .) Oracle, Oracle.
,
.

, ! , Oracle , . , ,
, ,
alter system checkpoint. , . ,
, .
, Oracle LOG_CHECKPOINT_INTERVAL LOG_CHECKPOINT_
TIMEOUT. / ,
, . ,
() . OracleSi LOG_CHECKPOINT_TIMEOUT
.
, ,
.
. , . ,
, .

LOG_CHECKPOINT_INTERVAL ,
0 ( ) ,
.
LOG_CHECKPOINT_TIMEOUT (0 , OracleSi, 1800), ,

188

.
> . . (,
, . .). ,
, , ,
.
7.3 ( ) ,
CHECKPOINT_PROCESS=TRUE. ,
, , LGWR. ,
, , ( DBWR). OracleS
. ,
OracleS . ,
. ,
DML. .

, TRUE
LOG_CHECKPOINTS_TO_ALERT. ,
.

OracleS,
.
,
.
, - ,
Oracle .
"checkpoint not complete" ( ) , , .
, Oracle
(. . . , .), .

189

, Oracle
. ,

.

, LGWR
. . , .
(, ,
). Oracle .
/.

. Oracle,
,
. , .


: "
?" ,
, LOG_BUFFR, . .
,
, , ( . ) (,
, ). , , . ,
, .
,
, ARCH.
! .
OracleSi, FAST_START_IO_TARGET. /,

190

. , DBWR
.
, - . .
. ! , ,
.
: " ?". , Oracle ,
, .
, : . , .
, ,
, DBWR
, LGWR
. LGWR
,
checkpoint cannot complete. ,
, . , , 50%
.
25% . ( ,
OraPub Inc.) ,
.
,
.

'

' -

archivelog,
ARCH. (
Oracle). , - ,
, , .
. , ,

191

LOG_ARCHIVE_BUFFERS LOG_ARCHIVE_
BUFFER_SIZE. , , OracleSi. Oracle , ,
. , , .
, .
.
. Oracle ()
/.
. Oracle " " ,

.

, , .
LOG_ARCHIVE_START

TRUE .
, archivelog.

LOG_ARCHIVE_FORMAT
LOG_ARCHIVE_DEST

,
. OracleS
(, LOG_ARCHIVE_DUPLX_DEST)
.
, LOG_ARCHIVE_DEST_n (
1 5)
.

. ,

(
),

.

192

LOG ARCHIVE,
MIN SUCCEED DEST

,

ARCH. 1.
,
"" ,
.
,
Oracle .
.

LOG ARCHIVE BUFFER SIZE

,
ARCH. OracleSi.

LOG ARCHIVE BUFFERS

, .
1.
OracleSi.

LOG CHECKPOINT INTERVAL

,
. (
) 0.

. 0.

LOG CHECKPOINT TIMEOUT

, ,
,
(
) . ,

. Oracle 8.1.7 1800 .
, .
.

LOG CHECKPOINTS TO ALERT

Oracle
. ,
,
(. . ,
- . .).

FAST START IO TARGET


/, SMON
( ) . ,
, DBWR
.

ARCHJO.SLAVES
LGWRJO_SLAVES

, Oracle,

/ ARCH LGWR.
OracleSi. ARCHJO_SLAVES
Oracle, LOG_ARCHIVE_MAX_PROCESSES.

193

Oracle
OracleS 1997 . , :




(
), . ,
OracleG Oracle?, , ( ).
OracleS. ,
, . ,
Oracle6 Oracle?. - . ' ,
.
, OracleS : ,
. , ?
OracleS " Oracle ". , , ,
. , OracleS ,
Oracle 56 . ,
, !
, ,

. , ,
, .^ ,
, Oracle, .


, -

194

, .



.

.

. , ,
. , , , .
, Oracle 8.0.5, . Oracle Corporation
, Oracle Open World 1999 .
Oracle,
(Probal Shome. "Using Stored Outlines in OracleSi for Plan Stability") . :
, . , .
OPTIMIZER__MA>ePERMUTATIONS
, , , .
, , ( ) .
, .
, .
OPTIMIZER_MAX_PERMUTATIONS 80.^00. (, 79000), ,
,
. ,

195

79000 . , .
( ) , .
, .
OPTIMIZER_MAX_PERMUTATIONS SQL.
, SQL.

OPTIMIZER_INDEX_COST_ADJ
. , 100,
, , 50, ,
. OPTIMIZER_INDEX_COST_ADJ
.
.
1 10000. (,
1 10) ,
.

OPTIMIZER_SEARCH_LIMIT
5.
1, . (5),
( ) ,
FROM. ,

.
. ,
, , 1.

100
, 10000 .
, ,

. !
\

196

OPTIMIZER_INDEX_CACHING
, 0.
100. (, 99)

, . OPTIMIZER_INDEX_CACHING , HASHJOINJENABLED TRUE, a HASH_MULTIBLOCK_IO_COUNT
, (, DB_FILE_MULTIBLOCK_
READ_COUNT). , , , 99,
, . ,
,

(
HASHJOIN_ENABLED TRUE).
, ()
() () (), where () (). ,
. , .
99 , , .



. ,

USEJHASH.

198


1.

, .
Oracle. : Oracle .
,
. , .
, , , ,
. , .
, .
, 1000 ,
,
(DB_FILE_MULTIBLOCK_READ_COUNT * DB_BLOCK_SIZE).
, Oracle ,
. ,
/. ,
. ,
/.

(, : ,
, , ), ,
.

, , . , ,

199

, ( ) , , , . , ( /
) ,
, , .
, , , .
, pctfree, .
,
.
, ,
(
).
, , . , - , .
,
( ),
. , ROWID .
, Oracle, ,
. , Oracle ,
.
, , , ,
. , , pctfree (
) pctused ( .).
initial vCnex} (
'), maxextenfeiBbi ,
Oracle unlimited maxextents.

200

, , .
, , .
.
, .
Oracle .
1.
, Oracle.
,

.
, , ,
. , (,
Gary Dodge, Tim Gorman. OracleSi Data Warehousing),
Oracle.

Oracle -
. ,
( ) , , .
, - , , , . ,
!

, ,
. , ,
SQL. , :

201

/
?
?
?
,
?
?
,
(update) , -

?
/
/?


Oracle?

32- Oracle
16 . 64 64- Oracle.
Oracle ,
( Oracle
8.1.7). OracleQi ,
,
.
Oracle /. ,
. /, .



Oracle :
(
).
, "
". ,

,

( initrans freelists). ,

(. " :
").
83. 281

202


Oracle , (OLTP).
,
, .
, ,
initrans freelists. , , Oracle
. , .
/ ( ) ( ). , , , Oracle
. , ( ),
, , Oracle.

,
(ERP)
,
. , ,
, .




(, xfs, jfs, efs, vxfs)
( /),
Oracle 8 .

8 ,
, ,
.


Oracle ,
. , , :

__

203

DB_BLOCK_SIZE = ()
>=
\

( xfs, jfs, efs, vxfs)


Oracle,

(FS). :
DB_BLOCK_SIZE = FS >= .
' Oracle . ,
. (Volume Manager),
. Windows NT,
.
, Oracle
, / , Oracle.
.
8
4 , Oracle , 8 ( , 4 ). ,
, /
. Oracle 4 ,
8 , , / ,
Oracle. ,
50% / , ,
FS. (
Oracle 8 , FS 4 ), -
/ , ,
.
? ,
SGA Oracle. (

204

SGA
, SGA Oracle, ).
/, (page-in) (page-out)
() . , . /.
, .
, Oracle SGA
( DB_BLOCK_SIZE), , (
DB_BLOCK_SIZE FS) SGA Oracle.
, . Solaris , pagesize.
.
. .
( FS). ( FS)
, , DB_BLOCK_SIZE. , /
,
. ( /)
, .


Oracle.
UNIX
512 ufs.
, ,
,
8 .

8 (
FS). ufs,

8 .
4 , 8
.

205

:

-
, , , , , , init.ora
( DB_BLOCK_SIZE).
: "
".
Oracle
:
, ,
,
direct.

.
,
.
,
(
) .
: ,
,
. , OracleQi .

:

(Eyal Aronoff. "Oracle Database Block Size") Oracle
2 8 . , .
.

150000

150000

14100

3400

19

20

268

68

206

- (1 ). ,
8
75%. , Oracle , -
.
, Oracle ( 2 8 ), -
75%. , , 1
. , ,
/ , . Oracle
/, .


, ,

( ),
_1_11__
, (DB_BLOCK_SIZE *
DB_FILE_MULTIBLOCK_READ_COUNT)= -
/ . -
/
(. "
/").



DB_FILE_MULTIBLOCK_READ_COUNTHa
(32 ), Oracle
,
. ,
.
.

9 Oracle, .

207

, . , , ,
, .
, / .
,
' Oracle.



, , - pctused, pctjree, initrans,
maxtransufreelists.
.

pctused
, pctused, .

.
. (,
),
.
, Oracle - -
, , pctused. ( )
( insert), ,
(freelist), , . ( delete),
( ) .
, , , pctused. pctused ,
. , ,
pctused.
pctused, (
insert). , ( pctfree). pctjree . ,
, -

208

, , , . ,
, ,
Oracle. , , ,
. , , , -
. ,

. , ,
, .

pctused,
, . , , , .
, . , . , .
Oracle, .
pctused ,
.
,
.
/
.
pctused . ,
. ,
, , () .
, , , pctfree pctused.

pctfree

pctfree ( ) ,
. , ,

209

. ,
,
/.
Oracle pctfree, pctused .
. 25%, pctfree
25. , pctfree /. ,
25% .
pctfree 10%, , ( ),
.
pctfree , -
, .
,
.

initrans
Oracle , ( ) , , .
,
, . Oracle,
.
,
"" .
, , ,
, ,
, . ,
2 , (
) 2.
, , ,
- , ,
, - . ,

210

Oracle. " ".


initrans ( , ), ,
. initrans ! 2 . ,
( ,
), ,
24 pctfree . ,
:

, ,
,
.

,
pctfree ,
pctfree 24
.
, initrans , , Oracle, ,
.

maxtrans
maxtrans . ,
. maxtrans 255,
, 255 . , ,
. ,
255 .

, initrans -

211

, .
,
: , , ,
. , OLTP.
freelists, .

freelists

freelist- , . . ,
, freelists , .
" " , . (), .
( , pctfree), .
, pctused,
(freelist). 1.
, . ( )
.
,
freelists , ,
, . , , ' .
freelists,
freelists, . ,
, ,
.
, . , Oracle
freelist 5 . , - 40 ,

212

, 200 . ,

160 ( ).
, . , Oracle freelist
. freelist
, ,
, .


,
V$WAITSTAT
V$SYSSTAT. ,
Oracle buffer busy waits,
V$SESSION_WAIT,
.
,
buffer busy waits
freelist.

,

, ,
. . , ,
. OracleSi
,
. SQL
. , SMON.
, ,
OracleSi, ,

213

, . , ,
.



default space ( )
. ,
. ,
. , - , , 128 ,
128 -
ORA-1653 ORA-1654.

( ) ( ORA-1653 ORA-1654). ,
- . ,
.
- . (,
. - , .), : , , .
? . ,
. .
, ( ) ,
, .
( ) (
,
). : , ,
, . -

214

, ,
.
. 20 ,
.
( , ). ,
, , .
: ,
. , ( ,
) , Oracle . :

.
? , , .

, . , .
, , , SMON ""
. , ,
, , SMON.
SMON , .


-
, 1998 . OracleS 700 . (
Bhaskar Himatsingka, Juan Loaiza. Stop Defragmenting and Start Living.
http://metalink.oracle.com/cgi-bin/cr/getfile_
cr.cgi?239049.)
, . ,
,

215

, . :
1.
: , , .
2. .
3.
(initialvi next) . ,
initial next .
pctincrease
0. , pctincrease 0
, .
, SMON ,
pctincrease = 0, .
4.
, .
5. , ( tablespace)
, storage.

, .
6. ,
/ .
7. 1 6
( , ).
,
.
1: . .
? . . ( ) , , -
. , ,
, .
2: ,
. , , - ,
. , Segment_Type DBA_SEGMENTS.
2 ,

216

.
. .

64

, 256

, 1024

1024

3:
: Initial Next , initial next . ,
, , :
/
?
: ,
,
. , 2 ,
/.
,

?
: -,
. , :
truncate table drop table
.

.

(, sys.uet$
sys.fet$). SQL
( SQL,
SQL),
.

217


,
? ?
: , , .
2 ,
( ) , 4 .
.
,
, , .


?
: , .
. : ?
, ( / ),
,
.
initial next. .

initial next

256

16

,
, . , , 20000 .
16000 , 2500 - , 1000 - , , 500 .
, ,
, , .

218

256

16000

4,00

2500

2,44

1000

3,90

16

500

7,81

18, 15

, 20000
18,15 . $100 ( ) $1815.
, . 18 . , .
$1815 ,
- . , ,
,
, , , .

, 18 ( ).



, ,
Oracle
:
,
(
Oracle
). ,
,
.
,

.
,
DB_BLOCK_SIZE
.

219


,
,
. , ,
storage,
. OracleSi

,
. ,

compress=y.
,

.
,

,
.

Oracle 7.3
, create tablespace temporary.
. - ( ),
. SORT_DIRECT_WRITES (
OracleSi). TRUE, ,
, SORT_AREA_SIZE,
. , , , , .

Oracle 7.3. ,
.
Oracle 7.3 , ( , group by, order by, ,
. .) , , SORT_AREA_SIZE, -

220

() (temp) (
).
(). ,
, , SORT_AREA_SIZE, , .

.
Oracle 7.3 ,
, SORT_AREA_SIZE, ,
, . , .
( create tablespace,
TEMP).

( ).

. SMON (shutdown) (startup) ( shutdown immediate
abort). OracleS V$SORT_USAGE .



,
.



, . OracleSi
, -

221

,
. .
,
, ( commit
).
create global temporary table,
. , ,
,
. ( )
. on commit .

,
, . .
, : , , PGA , sort
areas. , , , SORT_AREA_SIZE,
.
, , , .

, .
OracIeSi
- . ,
. , - SQL,

.

222

. , , OracleSi
.

( ),
.

()
. ,
storage . ,
, :
,
. ,
.
,
. ,
,
extent management local autoallocate,
extent management local uniform size nnn extent management
local.
, Oracle
,
.

. extent management local
autoallocate create tablespace Oracle,
.
Oracle 64 , 1 ,
8 64 ,
.
,
. extent management local uniform 8m
create tablespace Oracle
8
, storage
.
: Oracle ,
storage (
).

223

. OracleSi
temporary, ,
:

Q Create Temporary Tablespace TEMP


Tempfile '/u01/oradata/prod/temp01.dbf size 1024m
Extent Management Local Uniform Size 8M;

,
,
DBA_TEMP_FILES DBA_DATA_FILES. tempfile

, .

:
, create temporary
tablespace, ,
nologging
.

V$TEMPFILE.



OracleS, " ".
.
. ( ) , , .
.
.

224


,
Oracle. :





,

. ,

.

OracleS , Oracle?.
Oracle? OracleS ,
, - , .
,
,

. Oracle?
OracleS. , ,
, - . , ,
,
.

" ",
. ,
. OracleS ROWID ,
. , ~>*-, , ,

225

.
/ ,
.
:

(
,
).
,
( ,
).
" ",
,
.


. .
OracleS.
Oracle:
,
:

.
where
.
, ,
,
-,
, ()
. , ,
.


.
,
,
, .
, ,

226

8
alter tablespace x offline.
, alter tablespace x online.


.
.
, .
,
, CHOOSE
Oracle OPTIMIZER_MODE. ,
( )
.
,
( )
.

(.
" ").
,
. ,
, .
, SALES
Month_No,
(, Month_No)
.
,
Month_No where .
,
.
. -,
(
). -,
--ROWID
,
, .

.
, , ,
, .
( Oracle 8.0 ,
, OracleSi
).

227

, ,
, , .
(T.JG.
)
. ,
?
-
.
, ,

:

(. .
).

.
,


(, , . .).

,
. ,


. '
,
parallel.
, ,
. ,
.
,

.
/. :

, ,
.
where ,
,
,
.

228

8

DML,
. . -,
, DML, -,
(
DML). (
)
alter index index_name
rebuild, , .



.
Oracle .
, .
Oracle

DB_BLOCK_SIZE

Oracle.

Oracle.

>

DB_RL_MULTlBlJOCK_READ_COUNT

/,
, Oracle
.
.

OPTIMIZER_MODE

,
SQL

SORT.AREASIZE

,
.

SORT_AREA_RETAINED_SIZE

,
. PGA
.

SORT DIRECT WRITES

,
, SORT_AREA_SIZE,
.
Oracle 7.3 ,
TRUE, OracleSi.

SORT MULTIBLOCK READ COUNT

OracleSi
, .
1 2.

229


( ) , (OLTP),
(DSS).
, , OLTP,
. , .
, . - .
.
, .
,
Oracle , OLTP DSS. ,
, , .
- 8 16 ? :
" , ".
, , ,
, -
.
, , Oracle . .
. :

230

8
,

DSS . , , :

"" (massaging)


, , ,
/

,
. ,
. , , ,
. ,
, ( ) , , .

,
,
. ,

DSS OLTP, ,
, (
, ), - .

. , ,
"". 007:
" !".




. , ,

231

, , .

. ,
100GB (VLDB, very large
database). VLDB
. , OLTP
VLDB . , , :




/ (. " /")



,




I SI

236


SQL
.

DML (OracleS ) . ,
, Oracle .
(
, ), ,
. .

., , , ! ,
. , : (PQ, Parallel Query), Oracle (OPS, Oracle Parallel
Server) ( Oracle9i - Real Application Clusters?).
. PQ.
, , ( -), PQ Oracle
Enterprise Edition ( Oracle )
Oracle.
Oracle SQL, ,
. , Oracle . ,
, .
. PQ - ^, ,
.


: - , , ? , -

237

? , , .
. , , , - ,
, .
.
, - , Oracle
Parallel Query, , , .


. ,
, ,
. ,
, ( )
, . , ,
.
, .
( )
,
/. ,
. PQ . ?
. , PQ
. ?
, , , . , PQ ,
.
, , , , .
SQL ,
:
, , ,
. . PQ SQL , -

238

.
, , . (slaves) , ,
, : , (PQC, parallel query coordinator).
PQ
. , PQ

. PQ, ,
, () .
, Oracle. , . PQ
!


,
SQL. () . PQ
. .


SQL
,

. PQ,
,

.
, , . :

239


SQL parallel
,
, , Oracle,

,..,
- ..
,
. "parallel (degree 4)"
, 4.
Q SQL> create table MYTABLE
(ColA number(2),
ColB number(2)
)

parallel (degree 4);


Table created!
'

'

- . * , . : ' .

'

'

/'"'

'

i -

'~

. '

'

/ ' . ' .

. ,
Degree USERJTABLES, ALL_TABLES DBAJTABLES:
Q SQL> select Degree
from USER_TABLES
where Table_Name = 'MYTABLE';
DEGREE

, alter
table. 6:
Q SQL> alter table MYTABLE parallel (degree 6);
Table altered.
SQL>select Degree
from USER_TABLES
where Table_Name = 'MYTABLE';
DEGREE
6

, , 4. Oracle
USER_INDEXES, DBA_INDEXES
ALLJLNDEXES Degree, .

240

SQL> create index MYINDEX


on MYTABLE (ColA)
storage (initial 1M next 1M)
parallel (degree 4);
Index -created.
SQL> select Degree
from USEFLINDEXES
where Index_Name = 'MYINDEX';
DEGREE


,
,
.

1 ,
4
. ,

.

.

alter index, :

Q SQL> alter index MYINDEX parallel (degree 6);


Index altered.
sql> SELECT Degree
from USER_INDEXES
where Index_Name = 'MYINDEX 1 ;
DEGREE

, 6, PARALLEL SQL. , ,
, . :

241

Q select /*+ PARALLEL (CM, 6) */ Customer_Id Custid, Last_Contract_Yr Ley


from CUSTOMER_MASTER CM
order by Customer_Id;
CUSTID

LCY

*
101119153
2000
101119164
2000
101119197
2000
5065192 rows selected.

"order by" , Oracle


12 .
. Oracle 7.3 8.0
Oracle ,
, .
Q SQL> alter table MYTABLE parallel;
Table altered.
SQL> select Degree
from USER_TABLES
where Table_Name = 'MYTABLE';
DEGREE
DEFAULT

Oracle 8.1.6 PARALLEL_THREADS_PER_CPU, . . Oracle , ,


, . ,
V$SESSION_WAIT , . , , , .
: .
/
SQL ,

242

Oracle? , Oracle
:
1. SQL PARALLEL
2. ,
3.

.-

,
.

^

,
PQC . PQC
, .
, ,
, .
, , ( , )
, SQL.
. , , , :
,
.
, ,
, alter noparallel, . , SQL,
,
, NOPARALLEL.
Q SQL> alter table MYTABLE noparallel;
Table altered.
SQL> select /*+ NOPARALLEL */ count (*.)
from CUSTOMER_MASTER;
COUNT (*)
5065192

243

SQL,

, SQL , .
SQL , DDL DML.
Oracle 7.3, :
(select)
(update delete)
(insert create
table)
Create Table AS Select (CTAS)
( DDL)
, Oracle 8.0, DDL, :

DDL OracleS , . Oracle


DML (PDML),
(DML, Data Manipulation Language),
ANSI ( ), . PDML DML
. PDML
, , ,
.
.
PDML OLTP.
PDML .
PDML ,
. ,
. , ,
. , -

244

.
PDML "" (. . . - . .) DML. , ,
.
DML .
(
alter session) PDML, . PDML SQL ,
. DML alter session. , Oracle
.
DML, Oracle
. PARALLEL
.
PDML. DML ORA-J.2841,

. , , , commit rollback,
DML.
[ SQL> insert into MYTEST values (1);
1 row created.
SQL> alter session enable parallel dml;
ERROR:
ORA-12841: Cannot alter the session parallel DML state within a transaction
SQL> commit;
Commit complete.
SQL> alter session enable parallel dml;
Session altered.
SQL> update /*+PARALLEL (MYTABLE, 3) */ MYTABLE set Num=Num+4;
4800000 rows updated.
SQL> alter session disable parallel dml;
ERROR:
ORA-12841: Cannot alter the session parallel DML state within a transaction
SQL> commit;
Commit complete.
SQL> alter session disable parallel dml;
Session altered.

245

,

, . .
PARALLEL MIN SERVERS


,
. - 0.

PARALLEL MAX SERVERS



, Oracle
. - 5.

PARALLEL MIN PERCENT

(
)
,
. - 0.

PARALLEL SERVER IDLE TIME

, Oracle 7.1 Oracle 8.0,


8.1.3.
, Oracle
. - 5 .

PARALLEL AUTOMATIC TUNING

, Oracle 8.1. TRUE,


Oracle
.
.

PARALLEL ADAPTIVE MULTI USER

, Oracle 8.O. TRUE,


Oracle ,

. ,


.

PARALLEL EXECUTION MESSAGE SIZE

, Oracle 8.O.
.
2148 . Oracle,
Oracle 8.0.x , ,
16 32
. OracleSi
(16 ),
PQ TCP
UDP.

246

9
PARALLEL THREADS PER CPU

, Oracle 8.1.
.
,
2.

OPTIMIZER PERCENT PARALLEL

,
.

0.

LARGE POOL SIZE

, Oracle 8.O.
SGA. " ",
PARALLEL_AUTOMATIC_TUNING TRUE,
PARALLEL EXECUTION MESSAGE_SIZE
LARGE.TOOL_SIZE; LARGE_POOL_SIZ
init.ora,
18 .

SHARED POOL SIZE

SGA.
PARALLEL EXECUTION_MESSAGE SIZE
SHARED_POOL_SIZE.

RECOVERY PARALLELISM

,
.

SORT AREA SIZE


"sort" .

.

SORT AREA RETAINED SIZE

,
"fetch" .

.

SORT DIRECT WRITES

OracleSi.
TRUE Oracle
.
, TRUE Oracle 8.0
, PQ.

SORT MULTIBLXK READ COUNT

,
,
.
1 2
( ),
, 2.

. { '

, , , :

247

PARALLEL_MIN_SERVERS
PARALLEL_MAX_SERVERS
PARALLEL_MIN_PERCENT


PARALLEL_MIN_SERVERS,PARALLEL_MAX_SERVERS
PARALLEL_MIN_PERCENT
PARALLEL_MIN_SERVERS . PARALLEL_MAX_SERVERS, , ,
. , PARALLEL_MAX_SERVERS
, ,
/ , .
Oracle ,
, , PARALLEL_MAX_SERVERS.
, Oracle
. ( ) PARALLEL_SERVER_IDLE_TIME. Oracle 8.1.3,
, Oracle , , .
.
,
PARALLEL_MIN_SERVERS. PARALLEL_MIN_SERVERS
PARALLEL_MAX_SERVERS (. " ") .
PARALLEL_MIN_PERCENT . ,
. ( ), .
,
. ( )
PARALLEL_MIN_SERVERS, PARALLEL_MAX_SERVERS
PARALLEL_MIN_PERCENT:

/* The output from the following command has been formatted */

248

SVRMGR> show parameter parallel


NAME

TYPE

parallel_max_servers
parallel_fflin_percent
parallel_min_servers

integer
integer
integer

VALUE

8
50
4

, (8) . ,
- , , .
Oracle ,
.
PARALLEL_MIN^PERCENT 50% (. . ),
, Oracle ORA-12827, :
Q SOL> select /*+ PARALLEL (CM, 6) * / count (*)
from CUSTOMER_MASTER CM
where Custoiner_Bill_Num is not null;
select /+ PARALLEL (CM, 6) */ count (*)
*

ERROR at line 1:
ORA-12827: insufficient parallel query slaves available
PARALLEL_MIN_PERCENT
(0)
, PARALLEL_MAX_SERVERS, , ,
( _ ). , ,
,
. , -
() .
? , PARALLEL_MIN_PERCENT (100) ,
, . , . , ,

, . , , -

249

, , 0 .
, , OPTIMIZER_PERCENT_PARALLEL. .
PARALLEL_MIN_PERCENT, , .
- 0 100. - 0. ,
.
,
.
OracleSi - PARALLEL_AUTOMATIC_
TUNING. TRUE FALSE. FALSE. TRUE, Oracle
.
, TRUE PARALLEL_ADAPTIVE_
MULTI_USER, Oracle
,
. . , ? TRUE, , Oracle
PARALLEL_MIN_SERVERS PARALLEL_MIN_PERCENT 0,
PARALLEL_MAX_SERVERS - 40 160 .
.
.

, , .
,
. ,
, "" ,
.
, . ,
16 , . Oracle UNIX (

250

) , ,
16 . .
.
, "",
. PQ , , , . ,
, . , , ,
, ,
.
: 16 , , ? ,
, . , -
.
16 - , 16 ( ) ( ,
), , . , . ,
. , , , " /".


- - ,
Oracle.
, Oracle,
- ,
.
16 , , ,
. ,
, ,
. ,
, - .

, (
) .

, 16 .

251

, . , ,
. , , .
(), :
- Floor ( ,
,
).
.
.
/ . , , .
, , , ,
PARALLEL
, DML . .
" Oracle" " ".
._

-;:..''

.-.''.:.

. ' . . ",' . : , . .. ". ' ,tr...c; ; . ..<:". ;

DML

DML , .
. . PDML DML . PDML PQ,
.
/*+ APPEND */. Oracle ,
.
:,

,,

..; ...

,>.:.;

: -

; - -.,- , . .

PDML

* I

. .,

, ,
.
DML , ""

252

. . DML
, , .
PDML , ,
.
, PDML.
( ). / ,
DML.
,
.
, ,
,
PDML. , , 36 , 6 , , 12 ( ,
" "). ,
12 . ,
12
36 , PDML
36 .

PDML

PDML , , , , PDML:
Q select /*+ FULL (tablename) PARALLEL (tablename. 6) */ count(*) from
tablename;
. , Oracle 8.0.x . , PDML
, Oracle .
, RECOVERY_PARALLELISM , 1 (, 8, , Oracle,
, ), SMON

253

.
, ,
Oracle.

Oracle 8.1.3 (
) COMPATIBLE
8.1.3,
- (fast start
on-demand rollback)
(fast start parallel rollback),
, , .
,
.

(
).
.
,
FAST_START_PARALLEL_ROLLBACK.
-
- SMON
,
.

PDML
PDML . ,
Oracle , !
. PDML , - LOB ( )
, , , . .
"
Oracle" (Oracle Concepts Guide) .
, , ,
, PDML .
ENQUEUE_RESOURCES, DML_LOCKS,TRANSACTIONS
LOG_BUFFER. " Oracle" (Oracle Tuning Guide).

254


, , PQ. , PQ
, ?
, Oracle V$, PQ.
,
. V$PQ_SYSSTAT ,
PARALLEL_MAX_SERVERS.

V$PQ_SYSSTAT:
Q SQL>select Statistic, Value
from V$PQ_SYSSTAT;
STATISTIC
Servers Busy
Servers Idle
Servers Highwater
Server Sessions
Servers Started
Servers Shutdown
Servers Cleaned Up
Queries Initiated
DHL Initiated
DFO Trees
Sessions Active
Local Msgs Sent
Distr Msgs Sent
Local Msgs Recv'd
Distr Msgs Recv'd
15 rows selected.
SQL>

VALUE
6
0
6
8
2
0
0
2
0
2
2
6
0
12
0

- ,

PARALLEL_MIN_SERVERS PARALLEL_MAX_SERVERS. ,
Servers Busy
PARALLEL_MAX_SERVERS, ,
,

255

(,
). , Servers Busy , , PQ PARALLEL_MAX_
SERVERS.
Servers Busy , PARALLEL_MIN_SERVERS,
, Servers"Busy. , PQ.
, Sewers Started Servers Shutdown-
PQ. (. . ,
PARALLEL_MIN_SERVERS) PQ ,
( ) .. ,
PARALLEL_MIN_SERVERS. , Servers Highwater PQ.
Servers Busy, Servers Highwater, Servers
Shutdown Servers Started, PQ.
V$PQ_SESSTAT PQ, . , .
:
SQL> select Statistic, Last_Query, SessionJTotal
from V$PQ_SESSTAT;
STATISTIC
LAST_QUERY
SESSION_TOTAL

Queries Parallelized
DML Parallelized
DFO Trees

Server Threads
Allocation Height
Allocation Width
Local Msgs Sent
Distr Msgs Sent
Local Msgs Recv'd
Distr Msgs Recv'd
10 rows selected.
SQL>

1
0
1
4
4
1

114
0
114
0

342
'342
' -

: '<<-; . ',.':_ . .-..'

256

,
, Query Parallelized . Allocation Width , , Allocation
Height - PQ , a Server
Threads - PQ.
- V$PQ_SLAVE, PQ. PQ, ,
, . .

'258

10


. , .
jvq /

' : .

(, -:^;' : - \t-\>:-;::; ;*.: .-

;.

.-

- , ,
, , . . ,
, . . - ,
. ( /, ria, " /").
Oracle, ", ".
, , : "
?". : - . ,
,
() . , ! .
( Oracle ), .

(serialization) . ,
. ,
,
. - ().

259

,., Oracle? ,

- . , , , !
, , , ,
. Oracle ! ,
, Oracle
, , , . Oracle
.
-, !
, , , , ,
- , .
. : ,
?
.

Oracle
, , , , .
. ", ", Oracle
V$SYSTEM_EVENT,
V$SESSION_EVENT V$SESSION_WATT. , ,
, , /, SGA
( ). , SQL, .
V$, ,
V$WATTSTAT. .
, , . (freelists) "

260

10

". , , ,
. ,
.
.
, V$ROLLSTAT, V$SORT_SEGMENT
V$SORT_USAGE.
Oracle 7.3.x 50 , OracleSi 150.
, ,
. , . ,
.
V$LATCHNAME , V$LATCH_CHILDREN, , .

: , ?
Oracle .
- , Oracle . ( ) :
, . .
. ,
( ) . Oracle .
Oracle: .

.
. , , .
. :
Oracle ,
. ,
, ,

261

. ?
, . , : Oracle .
. , , , , ( ).
- , . , . Oracle,
, , - , . ,
, , ,
, " ".
Oracle.
. , .

Oracle , ( ), (SCN, system commit number)


() .
, DML. " initrans"
" ", , , , .
(ITL, interested transaction lists).
ITL :
(TID), (UBA, undo block address), ,
, SCN ,
. , , .
, ,
, ( )
. , , -

262

10

, .
.
..,:.., --
"(SGN, system change number),
1
' (SCN, system commit number), ,
(-, ;
' . -. .), ,
>". , , 1.
'-> "' 1 , ' 254, SCN.
( ) , , . (DBA, data
block address) , .
( - , ).
, Oracle SCN , .
ITL, , . ITL , , ,
.
, ( ) SCN, . ,
. ITL
,
( ITL ID ). ,
ITL.
, ITL SCN, , , . , .
, ITL . , , . , SCN
, . Oracle
. SCN ITL .
" ". , Oracle -

263

,
, .

, .
ID , ITL . -
( ), "ORA-01555 -Snapshot too old". , , , ,
, . , "Snapshot too old".


,
.
Oracle, ,
.
. ,
-,

(
).

.

Oracle ,
, . . .
() ,
minextents. .
, Oracle
.
wraps V$ROLLSTAT. , wraps
. , extends -

264

10

, minextents
.
wraps extends, . rbs02
( ),
2 minextents. 2
usn V$ROLLSTAT. , , .
wraps 1, , .
extends 0, extents 2 ( extends extents). writes.
() (extents) 3,
(writes) - 2, (extends) - 1. : Wraps
1 ,
. :
Rem Run the first set of deletes and look at the rollback segment
Rem statistics.
SVRMGR> select Usn, Extents, Wraps, Extends, Writes
2>
from V$ROLLSTAT;
USN

EXTENTS

WRAPS

EXTENDS

WRITES

0
2

0
0

0
0

1976
81605

2 rows selected.
Rem Run the second set of deletes and look at the rollback segment
Rem statistics.
SVRMGR> select Usn, Extents, Wraps, Extends, Writes
2>
USN

from V$ROLLSTAT;
EXTENTS
WRAPS

EXTENDS

WRITES

1976

2
2
1
0
204173
2 rows selected.
Rem If you go by various documentation that defines what a wrap is,
Rem we should not wrap until we rewrite over the first extent.
Rem That is impossible in the above scenario as there is only 1

265

flem transaction in our database and we are the only one using this
fiem rollback segment. We have just started writing to the second
Rem extent of the rollback segment and wraps rose to 1.
Rem Run the third set of deletes and look at the rollback segment
Rem statistics.
SVRMGR> select Usn, Extents, Wraps, Extends, Writes
2>
from V$ROLLSTAT;
USN
EXTENTS
WRAPS
EXTENDS
WRITES
0
2

8
2

0
1

2 rows selected.

'

0
0

1976
665350

Rem No extends or wraps this time, as all of the undo entries


Rem fit into the current extent. However, the number of writes
Rem has increased showing that we are still writing undo entries.
Rem Run the last set of deletes and look at the rollback segment
Rem statistics.
1
SVRMGR> select Usn, Extents, Wraps, Extends, Writes
2>
from V$ROLLSTAT;
USN
EXTENTS
WRAPS
EXTENDS WRITES
0
- 2

8
3

0
2

0
1

1976
716940

2 rows selected.
Rem Bingo, now you see the number of extents at 3 and the number
Rem of extends at 1.
,
, Oracle () , next_extent_size. extends
V$ROLLSTAT. Oracle .
, ,
, . , , ,
.
(
400 ),
( ,
103. 281

266

10

, Oracle 7.3). , 400 . , , , Oracle,


, .

DML
(, ), . , ,
ITL ( DML) , , .
.
, Oracle .

, , , . .
Oracle - UNDO_DIRECT_WRITES. He ,
!
,
, . ,
(, , ). , ,
,
, ,
, SCN,
.
, . . ,
, .
.
, .
( ) , , -

267

,
. , , , , .
, , ,
!
,
? , .
V$SYSTEM_
EVENT.
, buffer
busy waits. ,
, . :
Q SQL> select Event, Total_Waits, Time_Waited
2

from V$SYSTEM_EVENT

where Event = 'buffer busy waits';

EVENT

TOTAL_WAITS

buffer busy waits


SQL>

TIME_WAITED

106021

46654

, V$SYSTEM_EVENT () . V$SYSTEM_EVENT
baseline delta . V$SESSION_EVENT
baseline
delta . ,
V$SESSION_WAIT () buffer busy waits . 1 ( ) 2 ( ),
buffer busy waits ( , ,
).
DBA_DATA_FILES,
DBA_EXTENTS UET$, , . V$WAITSTAT ,
( ):
SQL> select *
2
from VSWAITSTAT
3
where Class in ('undo header',

'undo block');

268

10
CLASS
_-.
,

COUNT

undo header
undo block
2 rows selected.
SQL>

TIME

43931
34743

1922
1121

baseline delta. COUNT


TIME delta ,
, . ,
.
, , ? : . , .
- ,
? , .


, , , .

. , statspack.
, , ,

. 10-15 ,
. . , statspack, , ,
.
"" "".
- ,
.
. ,
. ,
, . -

269

, . ,
,
.
, , ,
,

. ,
, Oracle
.
.
, , , ,
.

V$ROLLSTAT , .
V$ROLLNAME ,
:
Q SQL> select N.Name, S.Xacts, S.Gets, S.Waits,
2
S.Extents, S.Wraps, S.Extends, S.Hwmsize
3
from V$ROLLNAME N, V$ROLLSTAT S
4
where N.Usn = S.Usn;
i
NAME

SYSTEM
R8S01
RBS02

XACTS

0
2
3

GETS

6925
56337
162501

WAITS

0
1877
2298

EXTENTS

WRAPS

EXTENDS

HWMSIZE

13
11
11

0
1247
1363

0
48
85

794624
2146304
2043904

3 rows selected.
gets ,
, waits , .
,
.
,
extends. xacts ,
. hwmsize ,

270

10

( ), - ,
extends - , .
, , .
,
extends. DBA_ROLLBACK_
SEGS:
SQL> select Segment_Name Name, Initial_Extent,

2
3
NAME

Next_Extent, Min_Extents
from DBA_ROLLBACK_SEGS;
INITIAL EXTENT

NEXT EXTENT

MIN_EXTENTS

53248
102400
102400

53248
.102400
102400

2
10
10

SYSTEM
RBS01
RBS02
3 rows selected.
SQL>

,
1 . , ,
hwmsize.
? , - ?
.

.
.
, , .
.
, . (
)

271

"ORA-01555 - Snapshot too


old".
. OLTP DSS. OLTP
, ,
.
,
OLTP, - . .

, . ,
. . :
1. Oracle V$TRANSACTION
iised_ublk ,
,
, .

.
,
,
,
.
SQL> select Max(Used_Ublk)
2

from V$TRANSACTION;

MAX(USEDJJBLK)
250

SQL>

2.
( ),
,
.
3.
2 ,
.

272

10

4. initial next
.
, Max(Used_Ublk) 250.
8192 , , , 2048000
(250x8192). 2
2097152 2 . , initials nextjyix 2 .
,
. (minextents),
. , Oracle, , minextents 20 (a initial next 2 ,
), "Snapshot too old"
. , , , .
minextents 20 . ,
, ( optimal) .
. minextents 20 ( , - ). ,
. writes
V$ROLLSTAT . - .

, DML,
.
, . V$ROLLSTAT writes , .
,
, . writes. writes.
, .
, . ,
initial, next minextents ,
. , , .

273

, , set transaction use rollback segment rbsOl, rbsOl - .


PL/SQL PL/SQL
dbms_transaction.use_rollback_segment. , . . . ,

.

?
OLTP : /4,
,
Oracle MAX_ROLLBACK_
SEGMENTS. 30, .

.
V$ROLLSTAT , , - optsize shrinks. initial,
next minextents,
optimal. optimal
, Oracle , optimal. ,
Oracle optimal. shrinks
. . , ,
optimal, . , (. . ), .

, -
maxextents, Oracle
.
optimal
, optimal , ,
optimal . ,

274

10

,
ORA-01555.
optimal.
.

optimal
,
.
,
.
, ,
optimal,
. ,
optimal,
ORA-01555.
.
,
(
public ()
).
,


:
TRANSACTIONSARANSACTIONS_PER_ROLLBACK_SEGMENT.
,
,
TRANSACTIONS_PER_ROLLBACK_SEGMENT,a
. -

ROLLBACK_SEGMENTS.
.

"ORA-01555 - Snapshot too old"



. , .

/

/ . -

275

,
.
,
, - , . . -,
, , . -, "" , ,
DML- . , !

,

ORA-01555 , .
Oracle SQL.
ANSI . Oracle ,
.
,
, ,
Oracle SCN , . , . , SCN
.
SCN. Oracle , SCN, ,
- , ,
.
,
. ,
,
. , ,
, ANSI, ( )
. , ,
Oracle ( ),
. , .-

276

10

,
. ,
READ ONLY,


, . , Oracle
(fast commit).
, , ,
. , .
, . .
, DBWR ITL, .

, ,
, ,
Oracle -01555.

.
. ,
. .
read-only ( ).
,
.

ID , .
,
, ORA-01555.
- SCN ITL. , ,
, . , .
.

277



Oracle . , OracleSi, .
, . Oracle , , SQL order by, group by, distinct, union, intersect
minus. -,
analyze . . ,
, .
Oracle ? , Oracle ,
.
Oracle TEMP, . , Oracle
( ) .
. , ,
, ?


, , ? - , , ( )
.

(space management transaction (ST) enqueue). ,
. Oracle
. - , !
ST.
, , (
SMON, ), ST , -

278

10

. ,
. ,
, Oracle
"ORA-01575 - Timeout waiting for space management resource". He , .
.
, . :
Q SQL> select Name, Value
2
from V$SYSSTAT
.3
NAME

where Name like '%sort%';


VALUE
j-

sorts (memory)
sorts (disk)
sorts (rows)
3 rows selected.
SQL>

77027
8471
138003699

, ,
( , ). ,
. . , , ,
, SORT_AREA_SIZE SORT_AREA_RETAINED_SIZE. SORT_AREA_SIZE ,
, ,
alter session set sort_area_
size<bytes>;. , .
SORT_AREA_SIZE
ST
.

,
initial
next. , Oracle 7.3.
, , , " " " ".

279

, , Oracle , .
Oracle SORT_AREA_SIZE . initial next :
(SORT_AREA_SIZE )(
1 4)

,

initials next
.
,
,

.
(
),
-
,
,
.
:
*
initial next pctincrease 0. ,
. ,
, SORT_AREA_SIZE.
- - , SORT_AREA_
SIZE , a SORT_AREA_RETAINED_SIZE .

V$SORT_USAGE ( ,
Oracle 8.0), , . .
, , TEMP. segblk#

- ,

>

280

10

, blocks - , .
SQL> select User, Session_Addr Saddr, Session_Num SerNbr,
2
Extents, Blocks, Segblk
3
from V$SORT_USAGE;
USER'

ACME
APRS

SADDR

SERNBR

95BCA778
95BCAFB8

7733
1550

TABLESPACE

TEMP
TEMP

EXTENTS

34
35

BLOCKS SEGBLK

4420
4550

12480
65650

2 rows selected. .,
SQL>

, Oracle ,
. V$SORT_SEGMENT
. ,
:

<>

Q SQL> select Tablespace_Name TSNAME, CurrentJJsers USERS, Total_Extents TOTEXT,


2
Total_Blocks TOTBLKS, Used_Extents USEDEXT, Used_Blocks USEDBLKS
3
from VSSORT SEGMENT;

TSNAME

USERS

TEMP

TOTEXT
211

TOTBLKS
27430

USEDEXT
211

USEDBLKS
27430

1 row selected.

, , -
:
Q

TSNAME

USERS

TEMP

TOTEXT
220

TOTBLKS

USEDEXT

USEDBLKS

28600

1 row selected.

V$SORT_SEGMENT
. .

281

, -
:

SQL> select Tablespace_Name TSNAME, .Max_Blocks,

2
3
TSNAME

Max_Used_Blocks, Max_Sort_Size, Max_Sort_Blocks


from V$SORT_SEGMENT;
MAX_BLOCKS

MAX_USED_BLOCKS

MAX_SORT_SIZE

MAX_SORT_BLOCKS

28600

28600

111

14430

TEMP

1 row selected.
SQL>
V$SORT_USAGE
V$SORT_SEGMENT OracleSi.
, OracleSi.
. "
" " ".
,
, .
, , . , ,
, .
ST OracleSi, ,
. " " " ". , Oracle,
.

- , , Oracle SGA. SGA ,


.
-

282

10

Oracle . ,
.
( Oracle 7.3
redo ). - , ,
, , .
, ,
SGA.
V$LATCHNAME,
.- , Oracle 7.3 OracleSi, 50 150.
. ,
, . , , / , .
, - .
.
, , .
, , , .
, : cache buffers Iru chain, redo copy cache
buffers chains. , .

DB_BLjOCK_LRU_LATCHES

/
, ()
LRU .
, ,
Oracle, 2-12
.
.
cache buffers Iru chain,
.
,
. ( SQL,
/).

283

LJOG_SIMULTANEOUS_COPIES

,
.
, 28 ,
Oracle,
.
.
redo copy,
.
, .
,
OracleSi, Oracle
. ,
Oracle 7.3.4,
.

_DB_BLOCK_HASH_BUCKETS

, ,
.
,
cache buffers chains.
,
.
, ,

. ,
DB_BLOCK_BUFFERS/4.
,
. ( SQL,
/).

,
: library cache/load/lock/pin. ,
library cache
SQL ,

.
" SQL" " - ".
,
, ,
", ".
V$SISTEM_EVENT V$SESSION_TVENT latch free. V$SESSION_WAIT ,
( 2). V$LATCH,
.

288

11


- ABC - " ".
Oracle,
, , . /
" " .

, , ,
. , .
, -.
, .
,

. , /. ,
,
/.
, , , . SQL ,
, ,
where SQL. (rowids), ,
, . ,
. , /, , / , ,
, . ,
/ ( ), (, -. , .) , , /,

289

/. / ,
40 60% ,
/.
( )
/.
, INDX DATA
( ,
), ,
/.

JXAIIID - , Oracle,
,
/ . RAID .
, RAID . , , RAID. RAID
, /
(VLDB, very large databases) Oracle.
/ RAID. RAID,
- , /. ,
Oracle RAID.
i

RAID
, , RAID
( ) / .
/. , , RAID
, . ,
"", -

290

11

, . !
RAID - - ,

. RAID
/ ,
. RAID , ,
Oracle.

RAID
RAID /.
RAID:
/ /. , ,
, ,
" "
, /.
! : RAID,
. RAID.
, , .
, , , . ,
, , . ,
, , /,
( ) /. , , .
- , : "
, ", ,
. ,
RAID

291

, .
! (
) ,
.
,
,
. . ,

. RAID
/,
, -
, . . , .
, RAID , . , RAID , , , -,
, , , , -, , , , .

RAID
RAID , , ,
. - RAID. /.
, ,
.
( , ) , , , ,
. Oracle . Oracle .
,
, /,
. ,
/
.

292

11

(. ) , ,
Oracle , RAID Oracle:

Oracle?

OracleS

32

65533 * (
,
)

1022

65536

1022

65533

254

1000

16

32

**

LOB

1 LONG/
LONGRAW

1000 LOBS

LOB

CHAR

255

2000

VARCHAR2

2000

4000

, (), 247, ,
RAID .
,
,
, .

,
. 99,999% ( !) --
.
, " 1' . , , . ,
*
** , Oracle 7.3

293

. -
:
/
. RAID.

RAID
RAID, : (striping), (mirroring) (parity).


"" ,
( " "). , , , /.
/ . ,
/ .
, .
200 ,
. , ,
( . - . .) , . - . (. .
) . /. /. .
. ,
, ,
20 . .
/.
, , , /
. , / , , ,
. , -

294

11

/ .
- . ,

/.

/ , /, .
11.1 (vl),
(1-4). (Datal) vl
/ (Datal 1Datal4). , Data2 /
(Data21-Data24).
11.1.
RAID
diskl

diskg

diskS

disM

Datal 1

Data12

Data13

Data14

Data21

Data22

Data23

Data24


.
. , ,
. -
, , , . :
. 15-20%. ,
, .
11.2 (vl) , (1-8). (Datal)
vl / 1-4, 5-8. 1-4 5-8 vl.

295

11.2.
( ) RAID
diski

disk2

diskS

disk4

diskS

diskG

disk?

diskS

Data11

Data12

Data 13

Data14

Data11

Data12

Data13

Data14

Data21

Data22

Data23

Data24

Data21

Data22

Data23

Data24


- .
RAID ,
. ,
, RAID,
, .
() , ( ) . RAID,
.
(, error
correction code),
RAID. .
.
, , .
, ( ) : , 2 + = 5, ? : = 3.
11.3 RAID 3
- vl, 5 (1-5). (Datal) , vl, / 1-4, Datal 5.
RAID, -.
.

11.3.

RAID
diski

disk2

diskS

disk4

disks

Datal 1

Datal 2

Datal 3

Datal 4

Parityl

Data21

Data22

Data23

Dato24

Parity2

296

_V

11

/, , (, )
. RAID,
, /.

RAID
RAID , , 'Volume manager" ( ),
Veritas, Sun HP. RAID
(host-based) RAID.
, , / -, . ,
.
RAID ,
, -.
, RAID. RAID
RAID .
, ,
, RAID.
, /. / .
/, -, - SCSI. ,
-,
. , , /. RAID , ( -), ,
, RAID.

RAID
RAID , , -

297

,
. RAID 0 7,
.
/ . / .

RAID
RAID ,
. , , .

/, (. 11.1).

RAID1
, RAID
.
. ,
, .
. ,
. RAID
RAID 0. ,
. RAID - '
- , (. 11.2).

RAIDO + 1
: , ,
. RAID 0 1 (
). , .
, "" .
RAID , , . ,
. , . 11.2
, 11 . 281

i 1

298

(), , , . , , (, Datall 1) - 1,
(
1-4). , / 50%.

RAID 1+0

: , , . RAID ,
RAID 0 + 1, .
, . ,
/ 50%. , .
11.4 RAID 1+0. ,
(, Datall 1) - 1, ( 2-4) . 1, 2-4
/. , RAID 10 RAID 1 + 0 ,
.

11.4.

RAID 1 + 0
diskl

disk2

diskS

disk4

disks

disk6

disk?

diskS

Data11

Datall

Data12

Data12

Data 13

Data13

Data14

Data14

Data21

Data21

Data22

Data22

Data23

Data23

Data24

Data24

RAID 2
RAID , / . ,
RAID 1, . RAID
,

299

, RAID 3, 5 7. .

RAID3

RAID
, RAID 2,
. / /.
RAID 3 , , , . , ,
, / ( ).
/ ,
, RAID 3 - , . 11.3
RAIDS.

RAID 4
, RAID 3, . . , ,
Network Appliance NetApp Filers.

RAIDS

, ,
RAID. , RAID 2, 3, 4 7,
. , , . RAID 5 ,
, ()
, . RAID 5 /
/ (IOPS, input/output per second).
, ,
( ) .

300

11

, ,
, / , , , ,
. , "" ,
, , , .

, . RAID 3,
, ,
, (), /.
11.5 RAID 5 , . (Datal-Data4)
, .
11.5.
RAID 5
diskl

disk2

diskS

disk4

diskS

Data11

Data 12

Data 13

Data14

Parity 1

Data21

Data22

Data23

Parity2

Data24

Data31

Data32

ParityS

Data33

Data34

Data41

Parity4

Data42

Data43

Data44

RAID 6
Ha RAID , . RAID 6
,
RAID 5. RAID 6 ( ),
. RAID
.

' 301

RAID?
RAID 3.
RAID 3 ,
( !). RAID 7 ,
/. RAID 7 ,
RAID 3, . RAID 7

RAID 3 , , RAID 7 .
RAID 7, ,
RAID 3, /, RAID 7.

RAID-S
, RAID 3/5. / . RAID

,
RAID 5.
, ,
,
.

Auto RAID

HP Auto RAID, , /, RAID ,


RAID 0 + 1 RAID 5, /. /
" " (
).
, . 64 .
-, RAID 5 ^
RAID 0 + 1, ,
. , ,
RAID 0 + 1 RAID 5, ,
. RAID, -

302

11

. ,
.
RAID Oracle , , Oracle,
, , .
,
, . "" RAID 5 ( ),
. , .
Oracle.
Oracle,

/,
.
Auto RAID . RAID.
RAID

RAID 0

.
/ ( ).

RAID 1

.
.

RAID 0 + 1/
1+0

0 1 .
.
(, 1 + 0 0 + 1
).

RAID 2

,
.
RAID 3, RAID 5 RAID 7, .

RAID 3

/
.
.

,
IOPS. ,
.

303

RAID 4


.
,
.

RAID 5

.
.
.
, ,
IOPS .
.

RAID

.
,
RAID 5. .

RAID 7

, RAID 3,
.
/ RAID 3,
, RAID 3.

RAID-S

RAID 3/5 EMC.

Auto RAID

RAID HP,
/, /,
RAID.

Oracle RAID
RAID ( ), ( ),
() Oracle. RAID " " , .
/ Oracle. Oracle
RAID. , "
" . , RAID, ,

.

RAID1
RAID
,

304

11

,
. ,
, LGWR ,
ARCH . ,
RAID 1 LGWR ARCH. ,
.

RAID 0 + 1 RAID 1+0


- RAID 0 + 1/1 + 0,
RAID 3/5. , RAID 0 + 1/1 + 0
/
. RAID 3, 5
7, . RAID 0 + 1/1 + 0 , RAID 3/5/7.
, RAID 1 + 0 ,
RAIDS 0 + 1.

RAID 3 RAID 5
RAID 3 RAID 5?
: " ".
/ ( /), /.
RAID 3
,
. ,
RAID 3 .
/ (, , ).
, RAID 5 ,
.
RAID 5 . , , /
.
, RAID 3
(DSS, decision support systems) -

305

(DW, data warehousing) , ,


, . , RAID 5
IOPS
DSS/DW
.
?

. report.txt,
utlbstat/utlestat. , /, , RAID 3.

13 /, RAID 5
9 /. , , RAID 3 , , ,
, , . - .

1?7

RAID 3 /,
, RAID 7. -
, RAID 7
.


RAID 3 RAID 5,
IOPS

.
,

RAID 0+1/1+0.
RAID 3,
, ,
RAID 7
.

306

11

RAID 7 ( ),
RAID 3
/ .


, RAID 7
RAID 3.
.

Auto RAID
, Auto RAID HP ,
RAID 0 + 1 RAID 5 , / . Oracle (RBS, rollback segments)
(TEMP) .
/ , .
, RAID
RAID, . ,
/.
, ,
(
), , . , ,

,
, .
,
RBS ,
(
), , , RAID 5. , ,

307

RAID 5. , . ,
/ , RAID 0 + 1 .
TEMP.
RAID Oracle:
RAID

RAID

Oracle,

,
. ,
DDL
.

'
RAID1


. -
.
(, )
.

RAID 0 + 1 1 +0

,
/,
(OLTP) ,
/. ,
1 + 0 0 + 1.

RAID3

/
,
( ) .
, RAID 3 ,
RAID 5.

RAIDS

/
,
() . RAID 5
IOPS, RAID 3.

RAID?

/ ,
, RAID 3.

( ) . RAID 3
IOPS, (
), RAID 7
.

308

11


, RAID.
. ,
. ,
, '
( ) , .
, ,
/ . , RAID
. " ", ,
, .
, :
RAID ,
/ .
, ,
RAID.
, 60:40
: ,
, .
,
.
,
,

, . (
Oracle , ,
) .
,
, ,
,
. ,
18 .
,
, ,

,
. ,

.

309

.
,
.
(daisy-chain) .
/ .
/ .

,
/
. (
).
, , ,
:
= ( /
)/ ( / )



. ,
,
100 /,
10 /,
.
, ,
,
, .


:
: , ,
. RAID : , . ,
RAID.
""
, RAID,
( ).
,
/.
, -

310

11

/ ,
.
/, (. . , ).
/ , , , /
. , , (
),
Oracle /,
. , . ,
( , , )
, .
.
, Oracle 101 ( )
. , DATA, INDX, RBS, TEMP
SYSTEM . ,
(OFA, optimal flexible architecture).

, ,

, SYSTEM, RBS
TEMP. RBS TEMP
,
(

SORT_AREA_SIZE). ,

.
SYSTEM, RBS
TEMP. / SYSTEM
,

(
Oracle SHARED_POOL_SIZE).

311

, 1

, ,
:
1. , 2, : 2, 4, 8,
16 . . , DB_BLOCK_SIZE
2 (8k, 16k, 32k ..) DB_FILE_MULTIBLOCK_
READ_COUNT 2. ,
RAID 3, 5 7 ,
, +1.
2. DATA ( 4 8,
16 ). ,
RAID DATA.
3. INDX ( 2 4,
8 ). ,
RAID INDX. INDX
, DATA,
, ,
.
4. DATA INDX
,
/,
. , 16 , 16
, 16-
(
,
16 ). 16 ,
16- RAID 16 .
, 16- ,
,
16 .
, , ,
.
5.
/ . /
,

. Solaris /etc/system,
, maxphys.
, 128
, /
. ,

312

11

, 1
4 . , Veritas,
vxio:vol_maxio 512-
2048 ( 1 )
8192 (4 ).
6.


, -
200 / .
,
. ,
200 /
200 /,
, , 1 (
4 ). Solaris
maxcontig mkfs.
fstyp -v <device
namex maxcontig
, fstyp
(bsize) .
(maxcontig x bsize).
, tunefs
vxtunefs.
,
/,
.

7. 1-6
, .
, , ,
,
= ( , ,
).

. , / (maxphys)
1
1 ,
.


RAID , :

313

, , ,
/,
(
). , , ,

/,
.
/.
/ (. . )

/ .
, RAID
/ ( 5
" ", 1)
/ /. ,

. ,
-
/ .
/ ,

/.
, , / 1 , RAID 8,
8,
- 1 . , 1 .
(, Solaris 2.6/2.7)
/ ( maxphys). / , RAID.


Oracle
DB_FILE_MULTIBLOCK_READ_COUNT. Oracle

.
-
,
.
123. 281

314

,
, , DB_FILE_
MULTIBLOCK_READ_COUNT ,
Oracle .
Oracle 7.3 ,
, ( )
.

, 2
, :
1. .
2.
( ).
3. " "
RAID
.
.
4. 0 minfree,
Oracle

. 0
10% ,
.
: 5.
:
6. DB_BLOCK_SIZE = =

7. 8
. ,
Oracle DB_BLOCL_SIZE, 8
: ! - . : (. " ").
8. /
, ,

.

315

, . ,
i
.
/dev/null.
: timex dd if= /u08/oradata/acme/data01.dbf
of=/dev/null bs or bsize= stripe-width.
9. 8
: (#
bs/ ).


RAID
,
, .

, "write behind" ( :)

.
, write_pref_io
Veritas,
.
Oracle , VLDB
,
2048 .
, ,
(
) 10-15% RAM,
UNIX
(, HP-UX)
.
, . ,

50%
RAM.
, RAID,
,
. ,

.
.
-

316

11
,
, .

, ,
, ,
.
,
. Veritas

,

512 .

"" :

xfs, jfs vxfs ufs.


, (, ),
ufs. , ufs,
, .
Veritas Quick I/O
,
. , Quick I/O ,
DBWR ( ), .
, .
/,
, , .
Quick/Direct
I/O ( , ).

,
, -

317

Veritas Quick I/O Direct I/O ( ). ,


.
Oracle Parallel Server.

, Oracle, /, UNIX
. / Solaris AIX.
/ , Direct I/O Quick I/O
vxfs Veritas. ,
Oracle .
/, ,
. " " , / Solaris, HP-UX AIX.



, , Oracle. / .
, ,

.

, , .
/ " " . , ,
.

318

11

, / .

,
, DATA INDX . ,
, , DATA INDX .
.
'

'

"

.- 1

,
. Oracle,
. , (
temporary). ,
:

.
,
,
.
,
( nologging SQJL*Loader
nologging
/*+ APPEND */ ).
,

, . ,
SORT_AREA_SIZE
. Oracle 7.3,
Oracle SORT_AREA_SIZE

319

,
,
, .
,
SORT_AREA_SIZE
.

DATA, INDX RBS .
/. , , ARCH , ,
.
RBS TEMP,
SORT_AREA_SIZE
(sorts on disk) (undo
entries for rollback).

""

,
"", (. . . - . .). /
, RAID. , , /
, .
/ ,
.

, :
, .
, / ,
.

, , -

320

11

/ .
- .
, . NOARCHIVELOG, ,
RAID 1. ,
ARCHIVELOG,
.
RAID 1. . .
, 9 18 . ,
, , .
9 ,
9 . , .
. , , 250 1 , . .
Oracle . , ,
/ , Oracle.
SYSTEM

TEMP RBS. , . /
SYSTEM SHARED_POOL_SIZE DB_BLOCK_BUFFERS.

,
/
, RAID Oracle. Oracle
,
8 / 128 .

321

_DB_BLXK_CHECKPOINT_BATCH

16

DBWR
,
.

DB FILE MULTIBLOCK READ COUNT

16

.

.

.

DB WRITER PROCESSES

DBWR,
.

.
DBWR_IO_SLAVES,
DB_WRITER_PROCESS.
;'

DBWR 10 SLAVES

N
() /,
.

DISK ASYNCH 10

False

/,
UNIX
.
,
Oracle /
, - ,
TRUE.

HASH MULTIBLOCK 10 COUNT

16

/
.

USE DIRECT IO

True

Direct I/O,
.

.

RAID Oracle:
, RAID, , ,
VLDB, . :
, OLTP,
DB_BLOCK_SIZE (
)
.

322

11
.
/ (

/) .

.
(
),
RAID.
, , /
.
.

RAID
/ . ,
: 80% /
20% . 20%.
,
, /
RAID,
, .
, , ,
,

/.
,
,
, .
(MTTR, mean
time to recover), , .
,
.
,
,

RAID,
. ?
-
.

323

RAID
RAID, . .
RAID, /, , , .
:

. 11.1 RAID 0 + 1,
84 18 , 5-7 /, ( ), 100 /.
. 11.2 RAID 0 + 1.
. 11.3 RAID 3, 180 9 ,
10 /, ( ), 100 /.
. 11.4 RAID 3.
. 11.5 RAID 3.
. 11.6 RAID 5, 150
18 , 5-7
/, ( 1 2 3), 100 /.
. 11.7 RAID 5.
. 11.8 RAID 5.

324

11

u!2

Datal.Cntrll.ctl

Datal,Cntrll.ctl

u!5

Data2, Cntrl2,ctl

Data4, Cntrl4,ctl

Xl09

Ul8

, Sys, Rbs, Temp

Archived Logs

. 11.1. RAID 0 + 1

0 + 1 ( 1 2)


. 11.2. RAID 0 + 1

325

/
RAIDS
1

u!9

u20
Archived Logs

u21
, Sysl.Resl;
_Templ,-Gnlrij_

u06

U22

Data2

Res3,Temp9

u23
^Rbs2, Temp2, Cntrlg^

u24
Res4, Temp4

. 11.3. RAID 3
RAID 3 ( 1 2)

t.ii

. 11.4. RAID 3

326

11

RAID 3 ( 3)

ijilijiliiiiiiilili.

. 11.5. RAID 3
RAIDS
1

u!9
!2

Sysl.Resil,
Tempi l.Cntrll

jDaia.l, Cntrll.ctl
Tempi!, Cntrl2
U21

Ul5

Data2, Cntrl2.ctl

:Data4, Cntrl4,ctl

Archived Logs

Ul8

i: Archived Lugs

. 11.6. RAID 5

327

RAID 5 ( 1 2)

. 11.7. RAID 5
RAID 3 ( 3)

111 }.1;..!.,I

. 11.8. RAID 5

330

12


SGA
. SGA
.

UNIX ,
SGA .
,
SGA .
Oracle SGA , . UNIX ,
.
, UNIX, .
UNIX , SGA
.
, , .
,
(NUMA, non-uniform memory access), , (interconnect) . SGA

, , , , Oracle SGA.
, , , ,
. ,
Sun Solaris Intimate Shared Memory (ISM), SHMMAX ,
SGA .

331

< ()? , ,
. . .
: -,
, , Oracle ;
-, ,
Oracle. UNIX . Oracle (ICG, Installation and Configuration
Guide) ,
. .
.
Windows NT , . , - .
.
Windows NT, , .

:
.

,
Oracle. () . , .
,
/. UNIX
sar vmstat. , /.
UNIX , .

332

12

Sun Solaris Adrian's Tool.


SimbEL (SE). Sun Microsystems Foglight Software.
Solaris . Sun
Microsystems. HP GlancePlus, AIX - System Performance
Toolbox (PTX). GlancePlus UNIX. ,
top.
.
Windows NT
Performance Monitor. ", "
.
, . , .
, Oracle. ,
UNIX,
. , . , ,
. , , , , .
, .
, , , Oracle ICG
.
UNIX . .
, UNIX, (
). Windows NT, .
,
.

RAM

,
-

333

.
( ), , ( ) " " (
Millcap. Performance Management: Myths & Facts), :
http://www.hotsos.com/.
(Neil Gunther. The Practical Performance Analyst),
McGraw-Hill 1998 .
, -,
, . (Craig Shallahammer. The Ratio Modeling Technique), http://www.orapub.com/. ,
, ,
.
,
. ,
( , . - , .) - .
, ,
.
, , ,
, , .
, ,
. ,
, ,
. , " ". ,
.
, .
, 16 , 1 . -,
. , "" 12,5%, . 16
1 , 64 . , ,

334

12

12,5%. , , 16- 2 . 16- .


, , ,
500 ,
512 . ,
500 ( ), , , 1 .

,
.


, ,
, Oracle.

SGA Oracle ( )

- 50

-15

(
)

- 35


. , PGA .

50% Oracle

- 50% , SGA Oracle. . ,
.
SGA Oracle

- 80

- 12

-1

- 0,1

335

, . 2 100
, 64 ,
.

()

SGA Oracle

- 1024

- 306

- 694
v

PGA Oracle
694 . G 100 PGA ~ 7 . , SORT_AREA_SIZE
PGA, .
SGA Oracle.
SGA Oracle

()

- 800

-128-188

-8

-1



. ,

.

.


, , , , . -

336

12

.
10-15% .
, UNIX ,
, . ,

50% .



(Virtual Memory model). .
( swapping - , . . .) (paging space - . . .). , ,
. ,
, .
, . , SGA
( ) , (
). , , ,
.
SGA,
SGA.

() SGA Oracle

Oracle LOCK_SGA MLOCK_SGA ( Sun Solaris


USE_ISM _USE_ISM). TRUE, SGA
. MLOCK_SGA
LOCKJSGA ,
SGA, . ,
, , ,
, , SGA -

337

. , , . ,
, , .

UNIX

UNIX,
Oracle ,
. Oracle
. ,
, .
, , . , ,
. , , UNIX . "" sema - phore - .
, - . ,
, - .
, ,
.
, .
( ) , ,
. - ( )
UNIX, . Oracle ,
.
Oracle , .
, SGA.
.
. UNIX System V ( UNIX. - . .).
, .
AIX - IBM - ,
- (post-wait driver),
.

, -

338

12

. -
. , ,
(,
/). Oracle
-, ,
.
. , ICG
Oracle, . (,
(ERP, enterprise resource planning)
). ,
Oracle,
, , .

SHMMAX


. Oracle
,
SGA. , SGA
,

, .

SHMMIN


. .

SHMMNI


. .

SHMSEG


, .

SEMMNS


.
, SGA Oracle
. ,
1 , Oracle 1
,
.
,
. Oracle
, ,
, ,
-
SGA .

339

SEMMNI

.
UNIX .
,
SEMMSL

SEMMSL

, ,
.
.
. , UNIX
. UNIX ,
.

maxusers

.
, , nfile maxuprc. ,
.
UNIX,
, .

, .
Oracle.
, .
, SEMMNS.

nfile

, .
,
.
. ,
.

maxuprc

.
,
. Oracle ,
oracle.

, .

, UNIX, , . , .

340

12

Sun Solaris, AIX IBM,


HP-UX Windows NT.
.

Solaris
Sun Solaris - , , . Oracle
.
Sun Solaris , ,
, . Oracle
Solaris. ,
Solaris ( ).
(patched-up) Oracle,
. , .
Solaris vmstat, sar, iostat,
swap mpstat.
, . "
" ", "
sar vmstat. swap , a mpstat - .
. - truss - ( ). , Oracle
,
/ .
, .
, root,
, . , . , sysdef
, a dmesg , , , . .
Solaris.

341

/
/, , / , ,
/ (
). , , , ( - Oracle) "/ ". , Oracle
.
Solaris / : ( ) .
, Solaris 2.3. Solaris 2.4 / (, kernel asynchronous
I/O) . ,
Solaris (raw)
Quick I/O Veritas, . / ()
. / TRUE Oracle
DISK_ASYNNCH_IO. /, .
, / 1.

/
, ,
, /
. API

/ .
,
,
/,
/.
/
. Sun Microsystems,
,
, .
,
.

342

12

SGA
, (ISM, intimate
sharable memory) ,
Solaris .
, . ISM .
, SGA
. ISM ,
, SGA .
ISM,
, ().
Sun ISM Solaris 2.2.
. - Sun
Enterprise 10000 (1000) Solaris 2.6, , ISM. ,
ISM. : , -,
, , Oracle Metalink -
.
Oracle 8.0.x
USE_ISM TRUE, ISM - . (_USE_ISM) Oracle 8.I.3. ,
- TRUE. ISM, . Solaris ISM . -
ISM, /etc/system
:

shmsys:ism_off=1
shsmsys:share_page_table=1
/etc/system , ISM
Oracle . Oracle
, SGA, ISM.
.

343

IMS , SGA

. ,
SGA ISM ,

, SGA
. , ,
, Solaris
Unix.


Solaris 2.8
. ,
. ,
,
.
( ) ,
:
Q set fastscan =131072
set maxpgio=65536
set priority_paging=1
OLTP, ERP: SAP, Baan,
PeopleSoft, Oracle Applications . .-
SunWorldOnline Sun Blueprints. ,
,
Solaris 2.8 . ,
web- Sun (http://
www.sun.com/).

Sun Solaris. .

344

12

dmesg

/usr/sbin/dmesg

,
,

.

prtconf

/usr/sbin/prtconf

prtdiag

/Usr/platform/
<platform_name>/

,
platformjiame -
, ,
uname -i.

sbin/prtdiag

psrinfo

/usr/sbin/psrinfo

mpstat

/bin/mpstat

sysdef

/usr/sbin/sysdef

,

.

swap

usr/sbin/swap

-I
.

AIX
UNIX IBM. - . .
,
.
(SHMMAX) . AIX,
SGA 2 . Oracle ; Oracle Support
, Oracle AIX SGA .
Oracle -
.
? .

/
AIX / , (journalized) . ,

345


.
Oracle 7.3.x USE_ASYNCH_IO TRUE, aDB_WRITERS 1.
DB_WRITERS, /, 1.
OracleS DISK_ASYNCH_IO TRUE. DB_WRITER_PROCESSES 1 DBWR_IO_SLAVES.
AIX / , aioserver ( /).
kproc.
. / . , /,
. , minservers
/. , ,
/, maxseruers.
10.
minservers /.
/
/, ,
maxservers. ,
/ . minservers maxseruers, smit (smitty aio)
chdev:
# chdev -1 aioO -a maxservers = '20'
pstat, , / :
Q # pstat -a | grep aios | we -1
ps -k / kproc. , .
chdev pstat, root.
IBM 10 /
, .
. minservers maxservers/'2. ,
V

133. 281

346

12

/ , ,
.
, 20 , maxservers
200, a minseruers-100. , , maxservers 40, a minseruers- 20. maxservers minservers
. .
Isattr - -1 aioO, /.
:
Q oracle ibmrs601 [DBPR]: Isattr -E -1 aioO
minservers
25
MINIMUM number of servers
maxserve'rs
100
MAXIMUM number of servers
maxreqs
4096
Maximum number of REQUESTS
kprocprio
39
Server PRIORITY
autoconfig
available STATE to be configured at system restart
fastpath
enable
State of fast path
oracle ibmrs601 [DBPR]:

True
True
True
True
True
True

maxreqs /. . IBM
OracleSi JFS.
kprocprio / . / , .
AIX /. ,
IBM Support - aiostat, . ,
(, iostat), , . aiostat ,
/ . .
Q # aiostat 1

AIO requestcount:
AIO requestcount:
AIO requestcount: 22

347

requestcount: 61
AID requestcount: 52

requestcount: 80
requestcount: 64

requestcount: 5

requestcount:


/ AIX, aiostat
IBM Support. / . root.
, . !
/ , , , . ,
, ,
AIX.

SGA
AIX 4.3.3 Virtual Memory Manager (VMM). 1
v_pinshm,
"pin". Oracle 8.1.5, init.ora LOCK_SGA = TRUE, SGA "pin". SGA
, SGA. ,
. ,
, .
, ,
, .
v_pinshm, :
Q # /usr/examples/kernel/vmtune -S 1

, , vmtune, .

348

12

AIX 4.3.2
(-S) vmtune
v_pinshm, SGA
.


- .
, , ,
Oracle. .
AIX . AIX
Isps . , : -s
- , . .
LJ oracle ibmrs601 [DBPR]: Isps -s
Total Paging Space
Percent Used
3024
1%
oracle ibmrs601 [DBPR]: Isps
Page Space. Physical Volume
pagingOO
hdisk35
paging02
hdisk3

-a
Volume Group
Size
mdsvg
' 1000
oemvg
1000

hd6

rootvg

hdisk48

1024

%Used
1
1
1

Active Auto Type


yes yes
1y
yes yes
1v
yes

yes

1v

, , AIX . , , /,
. ( , ). AIX
,
. - minperm . vmtune , AIX , minperm (-p) (-).
80%, minperm- 20% .

349

, Oracle
SGA.
( ) , , . , vmtune minperm
(-) maxperm (-P):
# /usr/examples/kernel/vmtune - 15 - 50
. maxperm
AIX, Oracle. : vmtune .
, .
, . /etc/inittab.
vmtune /usr/examples/kernel.
. vmtune
, :
Q # /usr/examples/kernel/vmtune
vmtune:
current values:
-

minperm
183293
-W

-M

maxrandwrt maxpin
0
733995
-u

-R

-f

-F

maxperm minpgahead maxpgahead minfree maxfree


458746 2
8
120
128

-1

-w

npswarn
24192
-d

lvm_bufcnt Irubucket defps


9
131072
1

-k

npskill
6048

-c

-N

pd_npages
524288

-b

-B

numclust numfsbufs hd_pbuf_cnt


1
93
993

-s
-hsync_release_ilock
0

-n
nokilluid
0

-S
-L
-g
v_pinshm
lgpg_regions lgpg_size strictjnaxperm
0
0
0
0
number of valid memory pages = 917493
maxperm=50,0% of real memory
maximum pinable=80,0% of real memory
minperm=20,0% of real memory
number of file memory pages = 700018
numperm=76,3% of real memory

350

12

( ) minperm 20% 50% .


, .
man AIX . , -S v_pinshm -
0. , ? .
AIX. man
, .

chdev

/usr/sbin/chdev

.
root.

Isattr

/usr/sbin/lsattr

Isdev

/usr/sbin/lsdev

Isps

/usr/sbin/lsps

Islpp

/bin/lslpp

pstat

/usr/sbin/pstat


. -
.

/.
root.

vmtune

/usr/samples/kernel/vmtune

VMM
.
root.

HP-UX
HP-UX , . . ,
Oracle, . , ,
HP-UX, ,

351

()
. , , Oracle.
, Oracle - .
,
, .
HP-UX
. HP-UX
. sam (System Administration Manager).
sam, root. . , , ,
root. ,
, . sysdef .
, .
11.0 kmtune ( root ).
, - /usr/sbin/kmtune,
/usr/sbin PATH. ,
( root),
. kmtune, , ,
sysdef, .
. , , kmtune,
semmns. -q
, -1 - .
,
, .
prodhp[oracle]% /usr/sbin/kmtune -q semmns
Parameter
Value
semmns

2048

prodhp[oracle]% /usr/sbin/kmtune -1 -q semmns


Parameter:
semmns
Value:
2048
Default:
128
Minimum:
Module:

352

12


HP-UX. .

HP-UX /
. ,
/. / HP-UX, sain.
OracleSi HP-UX , /
HP-UX.

SGA
HP-UX .
. - MLOCK -
, . Oracle
(, , orack dba). , /etc/privgroup :
Q

dba MLOCK

/etc/privgroup , . setprivgrp -f/etc/privgroup , etc/privgroup.


.
/sbin/init.d/set_priv. . , , - LOCK_SGA TRUE,
.
SGA .
, . ,
, .
, , ,
Oracle, . .

353


HP-UX 10.x ( )
50% ( ).
. HP-UX (9.x 10.x) bufpages , 4096
. , .
HP-UX 10.x Hewlett-Packard bufpages 0, . HP-UX
50% . - dbc_max_pct dbc_min_pct - , .
dbc_max_pct , . 50% .
dbc_min_pct 5% .
( - /) , , dbc_max_pct.
( ), , , .
/ , , ,
, .
, , , , page outs (po) vmstat
%sys sar . ,
, layperson . / ,
.
. dbc_max_pct,

. , 15% dbc_max_^pct 2%
dbc_min_pct. Oracle dbc_max_pct, 128 .

/ -

354

12

. ,
/, , Oracle.
(VxFS) HP OnlineJFS,
. mincache=direct. ,
( ) ,
. ,
convosync mincache.
() ,
, .


HP-UX , . : , ,
.. "" (instructions) . maxtsiz. "" , , (
, ), . .
. maxdsiz . "" , , .
maxssiz,

, ,
32- . 64-
: maxtsiz_64bit,
maxdsiz_64bit maxssiz_64bit.
.
, 32- 64- . HP-UX.
maxdsiz 64 ,
.
maxdsiz,
. HP Oracle , maxdsiz - 1,9 .

355

maxssiz 8 . HP , 79 .
maxtsiz 4 . HP
, 1024 .

HP-UX 11.0. man
.

getprivgrp

/usr/bin/getprivgrp

,
, setprivgrp.

glance

/opt/perf/bin/glance

GlancePlus -
.

. .
Motif
gpm.

kmtune

/usr/sbin/kmtune


, .

setprivgrp

/usr/bin/setprivgrp


MLOCK, dba
() SGA .

swapinfo

/usr/sbin/swapinfo


.
root.

sysdef

/usr/sbin/sysdef

,
.


.


.
UNIX. Windows NT.
top

/usr/

Windows NT
Oracle Windows NT UNIX.
UNIX , ,
Oracle, -

356

12

(ID ). ,
SGA. . Windows NT (multithreading),
.
Oracle , Oracle.

Oracle. , . Oracle
.
SGA, , . ,
, .
-
, Oracle.
, ,
, , .
, , .
.
Windows NT ,
.
, Windows NT, Oracle,
, , (RAS, remote access server) /. , ,
,
. Oracle, Windows NT.

Windows NT
Windows NT - 32- ,
4 . Windows NT
( Windows NT 4.0) 2 , 2 . Windows NT Enterprise Edition , 4GB RAM Tuning (4GT).
3 , SGA . ,
boot.ini "/3GB".

357

Windows NT,
Intel. , ,
.

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems] multi(0)disk(0)rdisk(0) partition(2)\WINNT="Windows NT
Server Version 4.00"/3GB
multi(0)disk(0)rdisk(0) partition(2)\WINNT="Windows NT Server Version 4.00
[VGA mode]" /basevideo /sos

Oracle Windows NT , .
Oracle
- . Windows .NT . Windows NT
. Oracle , ,
. :
1. System
Settings
2. Performance.
3. Application Performance None.
4. .
5. .

Windows NT ,
, . Oracle
Windows NT TCP/IP.
, Windows NT, . ,
. :
1. Settings | Control Panel.

358

12
i

2. Network.

<

3. Protocols.
4. )' Network
Protocol.
5. Remove.
6. Yes .
7. 3 5 .
8. .
9. Control Panel.
- , , ,
Oracle, . , , ,
Oracle. :
1. Settings | Control Panel.
2. Network.
3. Bindings.
4. Show Bindings For.
5. Server,
.
6. , Oracle,
.
7. Move Up ,

.
8. , .
9. ,
Oracle, .
. , .
11. Control Panel.

359

Windows NT

Windows NT .
. ,
,
Oracle, ,
Oracle SGA. , Oracle.

Windows NT:
1. Settings | Control Panel.
2. Network.
3. Services.
4. Server Network Services.
5. Select Maximize Throughput For Network
Applications.
6. OK Server.
7. OK Network.
8. Control Panel.
9. .

"No Windows Dressing"


( - !)
.
.
. , - .
, .
Oracle.

(startup starting)?

,
,
. -

360

12

. ,
, Oracle.

Windows NT . . (paged-out)
pagefile.sys. , , . /,
- . , ,
. ,
( ),
. , :
1. Settings | Control Panel.
2. System.
3. Performance.
4. Virtual Memory Change.
5. Virtual Memory Initial Size Maximum
Size Paging File Size Selected Drive area (

)6. Set.
7. Virtual Memory.
8. OK System Properties.
9. Control Panel.
Microsoft , .
Windows
NT. Oracle Support, ,
Oracle. ,
- .

362

13

Oracle:

- - .
. ,

Oracle , , . - , ,
. , , .
: ,
. , (,
), , , ( ,
), ,
( , ). . , , .


Oracle?
, .
, , , , . , ,
.

,
Oracle : , .
Oracle .
, , ,
, ,

363

. "" , , , ,
, Oracle
,
.
. :
1. V$SYSTEM_EVENT ,
, , db file sequential
read ( ).
2. V$SESSION_EVENT ,
.
3. , V$SESSION_WAIT,
, , , - ,
, . .
4. 1-,
.
5. .
, .
6. ,
.
7. , SQL
.
8. , .
Oracle. ,
, Oracle.
9. , ,
, .
10. ,
.
11. ,
, .
, , , ,
, , ,
. , /,
. , -

364

13

90%, , . .
, , 99,999%, , Oracle , -
. Oracle ,
.

:
80% Oracle SQL. SQL
. , ,
,
SQL. ,
.
.

, , SQL SQL /*+HINT */. , , "",
.
SQL
, Oracle "" SQL. ,
SQL,
.
: 80%
SQL.

SQL:
1: , TIMED_STATISTICS TRUE
( init.ora
, alter system).
2. , MAX_DUMP_FILE_SIZE
. .

365

3. , USER_DUMP_DEST
,
. .
4.
SQLJTRACE.
5. .
6. .
7. tkprof ( )
, 4,
.
8. .
9. SQL.
10. 49,
.
SQLJTRACE, TKPROF, EXPLAIN PLAN AUTOTRACE -
,
Oracle. ,
.

. ,
Oracle
SQL, - , .


, Oracle,
, . .
SQL. , . , , .
, , . RMAN, MTS,
.
Java, Oracle Java.

. , . ,

366

13

. SHARED_POOL_SIZE.
,
SQL, ,
. , , , . SESSION_CACHED_CURSORS
Oracle.
(flushing)
. ,
,
, .
SQL, ,
. , , SGA -
.

,
, ORACLE-04031.
dbms_shared_pool . ,
. .
1

/ , V$SYSSTAT . ,
, /.
, ,
.
, , . ,

, .
. , , -

367

.
, SGA
.

DB_BLOCK_LRU_LATCHES . .
. , .
.
.
, Web. .
. (
, SQL, , . .).
. , , . Oracle
/. , Oracle ,
/ .
.



, , , . Oracle LOG_SIMULTANEOUS_COPIES ,
,
, OracleSi. , .
, LOG_BUFFER=131072 (128 ). 256 . ,
. ,

368

13

log buffer space. , ,


, log file switch, log file sync log file parallel write, ,
, /
. , ,
.
,
LOG_ARCHIVE_BUFFER_SIZE LOG_ARCHIVE_BUFFERS ( OracleSi). , , ,
.
, , ,
" ". , , ( , ).
, - ( ,
) , SQL

.
, OracleS.
Oracle, .


,
/. Oracle
, Oracle, . ,
.

, ,
pctfree pctused. initrans maxtrans ,
.
, freelists.

369


. , . : -
, .

OracleSi.
. ,
OracleS. , .
, ,
, . ,
, , ,
,
.
DB_FILE_MULTIBLOCK_READ_COUNT DB-BLOCK_SIZE. , ,
. , .


Parallel Query ( ) , , .
, , , ,
.
, , .
,
( ) .
" ".
, , , PQ /.
,
PQ. -

370

13

PARALLEL
SQL.
:
PARALLEL_MIN_SERVERS, PARALLEL_MAX_SERVERS PARALLEL_MIN_
PERCENT. ,
PARALLEL_MIN_PERCENT.
Oracle PARALLEL_AUTOMATIC_TUNING "" .
, , .
: LARGE_POOL_SIZE, SORT_AREA_SIZE
SORT_AREA_RETAINED_SIZE.
SQL, PQ.
OracleS, DML
DDL. DML DML . ,
PDML. PDML , , . /
. , , ,
, , .
V$PQ_SYSSTAT , PQ.
PARALLEL_MIN_SERVERS PARALLEL_MAX_
SERVERS.


,
. , . ,
.
- DSS OLTP.

371

DML. ORA-01555. ,
, ,
.
.
. .
, ,
.
, Oracle. . ,
. , (ST enqueue)
. initora SORT_AREA_SIZE SORT_AREA_RETAINED_SIZE .
, , .
. ,
, /
. , .
ST enqueue.
. , . ,
, . ! , , , , .
, Oracle, , . , , .
. , Oracle, ( ,
). , ,

372

13

.
- !
, .

.
.

/
/ ( RAID) . RAID
/ . ,
/. RAID, ,
, - . , ,
RAID. RAID
/. RAID:
RAID

RAID 0

, .
/ (
).

RAID 1

.
.

0 1 .
.
( , 1+0 , 0+1 ).

RAID 0+1/1+0

RAID 2


.
RAID 3, RAID 5
RAID 7.

RAID 3

/,
,
.

IOPS. ,
.

373

RAID 4


, , .
.

RAID 5

.
.
, .

, IOPS .
.

RAID 6

.
, -
RAID 5 . .

RAID 7

, RAID 3,
.
/, RAID 3, ,
RAID 3.

RAID-S

RAID 3/5 .

Auto RAID

RAID HP,
/
/ RAID.

Oracle RAID - . .
Oracle RAID:
RAID

RAID 0

Oracle.
,
. ,

DDL .

RAID 1

.
- .

(, )
.

RAID 0+1 1 +0

,
/,
(OLTP) ,
/. , 1+0
0+1.

374

13
RAID 3

/
, ( )
. ,
RAID 3 , RAID 5.

RAID 5

/
, ()
. RAID 5
IOPS, RAID 3.

RAID 7

/ ,
, RAID 3.
( )
. RAID 3 IOPS,
( ), RAID 7
.

DBA 101 , .
"", DATA
INDX. RAID : , .


: ,
, . . .
, Oracle
.
, , ,
. , /.
UNDC , Oracle

.
. , , , . -
/ , - SGA. -

375

,
. Windows NT ,
,
Windows NT. , Oracle , , !

...
: , !
Oracle. , .
. , , , .
, - . , ,
. Oracle. , ,
, !

- I

143. 281

^1~::

SP

380

_/ , .
AIX Advanced Interactive Executive UNIX
IBM.
Analyze DDL,
, .
.
^,
Archive Log ,
.
.
Auto RAID

, RAID, Auto

Autotrace SQL*Plus
SQL .
Bind SQL,
bind () ,
. . Parse, Define, Execute, Fetch.
CTD Compulsive tuning disorder ' ,
,
" -".
Define SQL, define
()
. . Parse,
Bind, Execute, Fetch.
Enqueue ,
, .
,
(. . . . .).
Execute SQL,
execute () , ,
( update, delete insert).
,
. . Parse, Define, Bind, Fetch.
Fetch select SQL

.
. . Parse, Define, Bind, Execute.
Init.ora Oracle,
.
ISM Intimate sharable memory .
Sun Solaris. ,
,
.

381

LRU Least recently used .


Metalink Oracle,
. URL web-: http://metalink.oracle.com.
Oracle
CSI.
MRU Most recently used .
OTN Oracle (Oracle Technology Network).
; URL
web- http://technet.oracle.com.
Oracle
.
Parse SQL,
,
.
SQL. .
Define, Bind, Execute, Fetch.
PDML Parallel data manipulation language
.
RAID Redundant array of independent or inexpensive disks
.

/ .
RAID,
.
RAID, Auto (Auto RAID) Hewlett
Packard, /
/,
RAID.
RAID 0 RAID,
/. ,
.
RAID 1 .
" ".

RAIDO.
RAID 0+1 " , ,
". RAID RAID 0 RAID 1,

, ,
.

382


i RAID 1+0 " , ,
". RAID
, RAID 0+1,
.
RAID 2 RAID .
.
, ,
. ,
RAID.
RAID 3 RAID 2 ,
.
,
, ,
/.
RAID 4 RAID 3,
. .
RAID 5
,
. ,
.
;

,
.
RAID 6 RAID,
. ,
,
, RAID 5.

.
RAID 7 RAID 3,
.
RAID S RAID 5/3 .
RMAN Recovery Manager . ,
OracleS .
Oracle
.
SCN System Commit Number . Oracle
()
.
,
DML. .
System Change Number.

383

SCSI Small computer serial interface


.
STATSPACK OracleSi,
STATSPACK
, /,
utlbstaf7utlestat.


( ).
Tkprof Transient kernel profile .
Oracle,
,
.
, .
(Offline)
', .
/ (Asynchronous I/O)
/, .
/ ,
/. /
,
. Oracle
/
. /
/.
(Database) . Oracle Database.
, (Database Buffer Cache) .
.
Oracle (Oracle Database) ,
.
(Cache, Library)
, SQL
. Oracle ,
, SQL.
,
SQL.
(Database Block) . .
(Blocks) Oracle,
2 32 .
8 ,
16
/ .
64- Oracle.

384

__

(Lock) , Oracle ,

. , ,
,
- . Oracle
.
(Large Pool) OraeleSi .
, ,
, RMAN,
.

.
(Buffer) ,
.
.
(Redo Log Buffer) ,
,
.
.
,
,
.
(Buffer Pools) ,
.
(keep pool), (recycle pool)
(default pool).
OracleSi
.
(Cache, Database Buffer) SGA
( ) ,
, , . .
.
/
,
.
/ (I/O) ( )
.
"" (Two-Pronged Approach)
( ) ,
(
""), Oracle ( "").
(Nested Loops) . .

385

(Temporary Table) ,
OracleSi. ,

. ,
, ,
.
. ,
,
.
(Temporary Segments)
, (join),
(group by), (order by),
create index.
(Histogram) ,
. Oracle

.
(SGA, System Global Area)
,
. SGA
,
.
(Bit Mapped Index) . ,
(Parse, Hard)
, Oracle
SQL ( ,
SQL). ,
,
.
(Latch)
.
(
)
, Oracle.
(Mirroring)
.
,
.
(Index) ,
. ,
, (ROWID) .
, *- (
() ).

386


, (Index, Bitmapped) ,

ROWID,
ROWID, ,
.
(Index, Function Based) ,
OracleSi,
, , upper, lower, round . .
,
,
.
(Wait Interface)
V$SYSTEM_EVENT,
V$SESSION_EVENT, V$SESSION_WAIT ,
10046.
(Contention)

.
(Checkpoint) ,
() (LGWR)
.
(Correlated Sub-Query)
. .
(Cache Hit Ratio)
, Oracle.
,
.
(Cursor) , SQL,
SQL
. , ,
SQL ,
SQL.
(Cache) ,
LRU MRU.
(Locally Managed
Tablespace) OracleSi .

(self-manage), . . ,

" ".
,
.

387

(Join Methods)

,
.
:
(Nested Loop)
,
.
(Sort Merge) ,
,
.
(Hash Joins)
. Oracle

.
(Multiversion Read
Consistency)

, .
.
: ,
.
(Parse, Soft) , Oracle
SQL,
.
(Shared Pool Area)
(SGA), ,
, ,
( ,
).
(Online)
, .
(Optimizer)
,
SQL.
(Optimizer, Rule-Based)
SQL

.
(Optimizer, Cost-Based)
SQL

.
.

388


(Open Cursor)

. .

(Parallel Query) ,
, (
) .
(Sub-Query) select (),
select ().
, ,
, .
(Hint)
, ,
SQL.
- /*+ HINT */.
() (Parallel Query
Slaves) , .
(DBWR, DBWn) (Database Writer)
Oracle,
. ( )
.
(LGWR) (Log Writer)
Oracle,
,
.
(Swap Space)
,
, . .
.
(ARCH ARCn) (Archiver Process)
Oracle (),
.

.
() (Checkpoint Process) OracleS

,
(LGWR). OracleSi,
(control file) /
, : " ".
, .
(Server Process) "" ,
SQL .

( )

389

( ,
).
(Default Pool ,
.
( OracleS), " "
, ,
, .
(Recycle Pool) ,
OracleS. ,
. ,

,
/.
(Keep Pool) , OracleS.
.
, ( /),

.
Java (Java Pool) OracleSi .

Java .
ARCHIVELOG (ARCHIVELOG Mode)
: ARCHIVELOG
NOARCHIVELOG. ARCHIVELOG
(ARCH)

.
(Reserved Area)
,
SQL,
PL/SQL, , ..
(Segment) Oracle,
. ,
, , , .
(Rollback Segment) ,
( ) ,
. ,
,
ROLLBACK.
(overwritten)
.


(Partitioning)
, ,
.
(Semaphores) ,
. Oracle
UNIX
,
.
(System Change Number)
( ).
, ,
,
. . SCN.
(Cache, Dictionary)
, .
SQL.
(Event) . .
(Wait Event) OracleS
200 . . ,
Oracle, Oracle
7.0.12, .
,
: idle
() non-idle (). non-idle ,
Oracle
, idle , Oracle
.
(Shared Memory) ,

. Oracle

(IPC, inter-process communication).
(Join)
( )
.
(Sort)
.
- (Sort-Merge)
. .
(Striping)
,
.
/, /.

391

(Paging) ,

()
() . .
.
(Cost Based Optimizer) .
.
(Raw Devices) ,
, ,
, Oracle.
(Table)
, .
, . .
(Tablespace) ,
.
.
,

.
(Tablespace, Temporary Type)
Oracle 7.3,
.
. ,
,

.
,
.
, .
.
Oracle (OFM, Oracle Performance
Management) ,
,
.
(Filesystem) ,
Oracle.
(Database Files) , ,
, ,
Oracle.
(Redo Log Files) ,
,
, .

392


(Background Processes) ,
. ,
(DBWR DBWn, Database Writer)
.
(LGWR, log writer)
.
(ARCH ARCn)
. OracleS
(, checkpoint process)
, LGWR.
(, PMON SMON)
, ,
. .
, Oracle.
(Fragmentation)
.
,
.
(Hash Join) . , .
(Extent) ,
.
(Instance) . Oracle.
Oracle (Oracle Instance)
, .

394

,
, . . Oracle exp, imp SQff
Loader. , Oracle (init.ora)
( ) ,
, ,
. ,
, , .

Export
Oracle 7.3
.
buffer
. single-task, .
Oracle 7.3
direct. Oracle SGA .
, . .
( ). , direct=y.
, recordlength, ( Oracle SGA) .
(bufsiz) . recordlength

.
, , .
Oracle 8.1.7,
AIX 4.3.3. , .
. timex.
.4 952 153 .

395

( -
)

412,81

recordlength= 16384

399,65

recordlength
DB_BLOCK_SIZE

buffer=1048576

251,79

recordlength

buffer=1048576 recordlength=16384

248,75

recordlength
DB_BLOCK.SIZE.

buffer=1048576 recordlength=65535

235,38

recordlength

direct=y

66,20

recordlength

direct=y recordlength=16384

51,85

recordlength
DB_BLOCK_SIZE

direct=y recordlength=65535

45,60

recordlength

, " direcf . , , recordlength.


. ,
, .

Import
, . ,
storage, .
. , ,

. , ignore^y, , .
commit=y . Oracle
commit . -

396

.
(commit=n), Oracle ( commit), ()
. (commit=y)
, , , ,
, Oracle .
.
indexes=n ( import=y). , . '
SORT_AREA_SIZE SORT_AREA_RETAINED_SIZE


.
nologging unrecoverable.
- ,
, ' ? ,
statistics^estimate ( Oracle?)
analyze=y ( OracleS).
. Oracle
statistics=none analyze=n.
, . ,
, , .

buffer. (___ _). ,
buffer. buffer ( ) .
, , .
Oracle 8.1.7, AIX 4.3.3.
, . .
timex. , , 4 952 153 . 65 .

397

commit=y indexes=n ignore=y

594,88

commit=y indexes=n ignore=y


buffer= 1048576

312,96


16131

commit=y indexes=n ignore=y


buffer=5242880

289,55


80860

commit=y indexes=n ignore=y


buffer=10485760

288,12


161320

, buffer 5
. , buffer, , buffer
. , ,
recordlength ( , -
).

SQL*Loader
Oracle
SQI?Loader. ,
. . Oracle insert (DML). ,
SQL ( )
.
Oracle ,
.
SGA .

, LOB, BLOBS, . .
, direct TRUE.
raws , . , -
. ( ) ,
paraUel=true. , . ,

398

__

.
, unrecoverable . , ,
(unusable),
.
,
rows. Oracle ,
, rows bindsize.
, (bind array).
, readsize, Oracle 8.0.5,
, , .
SQI?Loader bindsize readsize.
, , , Oracle
. SQI?Loader
ROWS bindsize
. bindsize readsize (65535 ):
Q Space allocated for bind array:
Total logical records read:
Total logical records rejected:
Run began on Wed Nov 10 18:30:22

24063
30
1999

Run ended on Wed Nov 10 18:37:18

1999

Elapsed time was:


CPU time was:

51084 bytes (2 rows)

00:06:56.51
00:01:34.72

bindsize readsize 1048576 (1 ), :

Space allocated for bind array:


Total logical records read:
Total logical records rejected:
Run began on Thu Nov 11 00:02:23
Run ended on Thu Nov 11 00:05:06
Elapsed time was:
CPU time was:

00:02:42/25
00:01:14.59
'

1047222 bytes (41 rows)


24063
30
1999
1999

399

? , ,
bindsize, readsize rows, .
, ( ) SQI? Loader 1999 .
,
(Stephen Andert. SQBLoader: A Case Study in Tuning) http://oracle.oreilly.
com/news/oraclesqlload_0401.html. , O'Reilly & Associates (Jonathan Gennick, Sanjay Mishra. Oracle SQBLoader:
The Definitive Guide) . SQEfLoader .

Oracle
Oracle, . ,
, .
, ( ) , .

, , .
DISK_ASYNCH_IO, DBWR_IO_SLAVES USE_DIRECT_IO. He
. " Oracle".
V$PARAMETER Description.
Q # initMYDB.ora
w

Modification History

# Name
# Kirti

# Gaja

Date
04/16/2001

04/17/2001

Action
Created the file

Cleaned up, added some parameters

400

# Parameters to optimize the Database Buffer Cache and I/O


4*

db_block_buffers = 10000
buffer_pool_keep = (buffers:500, lru_latches:.1)
# OracleS and above
buffer_pool_recycle = (buffers:1000, lru_latches:2)
n OracleS and above
db_file_multiblock_read_count = 16
db_writers = 1 0
# Oracle 7.3 and below
dbwr_writer_processes = 1
# Oracle 8 and above
dbwr_io_slaves = 1 0
# OracleS and above
disk_asynch_io = TRUE
# OracleS and above
use_direct_io = TRUE
# Platform specific
use_ism = TRUE
# Sun Solaris, Obsolete in Si
db_files = 200
# Parameters to optimize the Shared Pool Area

shared_pool_size = 134217728
shared_pool_reserved_size = 10485760
shared_pool_reserved_min_alloc = 5242880 # Obsolete in Oracle 8.1.3
java_pool_size = 20971520
# OracleSi and above
large_pool_size = 10485760
large_pool_min_alloc = 8192
# Obsolete in Oracle 8.1.3
lock_sga = TRUE
ft
Platform specific
mlock_sga = TRUE
ft
Platform specific
dml_locks = 300
sequence_cache_entries = 100
# Parameters to optimize Hash Joins
#

hash_area_size = 10485760
hash_multiblock_io_count = 16
hashjoin_enabled = TRUE
# Parameters to optimize Redo Log Buffer, ARCH and LGWR

^
log_buffer = 131072
log_archive_dest = /u06/oradata/MYDB/archive
log_archive_format = arch_%s.log
log_archive_start = TRUE
log_archive_buffer_size = 128
# Obsolete in Oracle 8.1.3
log_archive_buffers = 5
# Obsolete in Oracle 8.1.3

# OracleS and OracleSi introduced a few additional parameters to manage more


# than one log archive destination and conditions for copying log files
# to them. Please refer to Oracle documentation for additional information.
# Parameters to configure Latches
4+

log_simultaneous_copies = 8
dbj)lock_lru_latches = 8

# Obsolete in Oracle 8.1.3

# Parameters to optimize Checkpoints


4+

log_checkpoint_interval = 0
log_checkpoint_timeout = 1800
log_checkpoints_to_alert = TRUE
# Parameters to optimize Cursors and Library Cache Performance
#
.
i
cursor_space_for_time = FALSE
row_cache_cursor = 128
session_cached_cursors = 64

# Obsolete in Oracle 8.1.3

open_cursors = 256
# Parameters to select Optimizer Mode and tune Optimizer

optimizerjnode = choose
optimizer_parallel_percent = 0
optimizer_max_permutations = 79000
optimizer_index_cost_adj = 1
optimizer_search_limit = 1
optimizer_index_caching =99
partition_view_enabled = true
always_anti_join = HASH

# Oracle 8.0.5 and


# Oracle 8.0.5 and
# Oracle 8.0.5 and
# Oracle 8.0.5 and

above
above
above
above

ft Parameters to optimize Parallel Query Option

parallel_max_servers = 16
parallel_min_servers = 4
parallel_min_percent =50
parallel_server_idle_time = 5
parallel_automatic_tuning = FALSE

# Obsolete in Oracle 8.1.3


# Oracle8i and above

# Parameters to optimize Sort Performance

402

sort_area_size = 1048576
sort_area_retained_size = 1048576
sort_direct_writes = TRUE
sort_write_buffers = 8
sort_write_buffer_size = 32768
sort_multiblock_read_count = 2

#
#
it
n

Obsolete
Obsolete
Obsolete
OracleSi

in 8.1.3
in 8.1.3
in 8.1.3
and above,

Pointer to the configMYDB.ora file that stores static parameters


44

ifile = /u01/oracle/admin/MYDB/pfile/configMYDB.ora
configMYDB.ora

db_block_size = 8192
processes = 100
timed_statistics = TRUE
# The following parameter enables public read access to trace files
_trace_files_public = TRUE
global_names = TRUE
compatible = 8.1.6.1
rollback_segments = (rs1,rs2,rs3, rs4)
db_name = MYDB
control_files = (7u03/oradata/MYDB/cntrl1.ctl,\
/u04/oradata/MYDB/cntr!2.ctl)
user_dump_dest = /u01/oracle/admin/MYDB/udump
core_dump_dest = /u01/oracle/admin/MYDB/cdump
background_dump_dest = /u01/oracle/admin/MYDB/bdump
service name = MYOB


, ,
http://www.orapub.com, http://technet.oracle.com
http://metalink.oracle.com. Hotsos LLC Orapub Inc.
,
. , .
, Oracle,
,
oracle-l ( )

403

lazyDBA ( '). oracle-1, ListGuru@fatcity.com,


: your name, lazyDBA, ORACLEDBA-SUBSCRIBE@LAZYDBA.COM; http://www.lazyDBA.coni.
, web- Miracle A/S
http://www.miracleas.dk.
\

406

__

. , , .
.
Andert, S. SQJL*Loader:A Case Study in Tuning. O'Reilly White Paper, 2001.
http://oracle.oreilly.com/news/oraclesqlload_0401.html.
Aronoff, E. The Oracle Database Block Size - Larger is Better. White Paper,
Proceedings of the International Oracle User Group Americas, Live 1999,
1999. http://www.ioug.org.
Aronoff, E., K. Loney, and N. Sonawalla. Advanced Orach Tuning and
Administration. Osborne McGraw-Hill, 1997. http://www.osborne.com.
Cockroft, A. Sun Performance and Tuning, Spare & Solans. Sun Microsystems,
1997.
Dudar, E., D. Cook, and C. Shallahammer. The Ratio Modeling Technique.
White Paper, 1997. http://www.orapub.com.
Gunther, N. The Practical Performance Analyst. McGraw-Hill, 1998.
http://www.osborne.com.

Hewlett-Packard Corporation, HP-UX Kernel Tuning and Performance Guide.


Tuning Guide, 2000. http://docs.hp.eom/hpux/onlinedocs/os/ll.0/
tuningwp.html.

IBM Corporation, Performance Management Guide. AIX Performance Guide,


2000. http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/aixbman/
prftungd/t- oc.htm.
Lewis, J. Introduction to the Parallel Query Option. White Paper, Proceedings of
UK Oracle User Group, Spring 1997. http://www.jlcomp.demon.co.uk.
Lewis, J. Parallel Query Option in Real Life. White Paper, Proceedings of UK
Oracle User Group, Summer 1997. http://www.jlcomp.demon.co.uk.
Loney, K. and M. Theriault. OracleSi DBA Handbook. Osborne McGraw-Hill,
1999. http://www.osborne.com.
Massiglia, P. RAID for Enterprise Computing. Veritas Software Corporation
White Paper, 2000. http://www.veritas.com/.
McDougall, R. Getting to know the Solaris filesystem, Part 2. Sun Microsystems
White Paper, 1999. http://www.sunworld.com/sunworldonline/
swol-06-1999/swol-06-filesyste- m2_p.html.
Millsap, C. Performance Management: Myths & Facts. Hotsos White Paper.
http://www.hotsos.com.

407

Millsap, . Why 99% Cache Hit Ratio Is Not OK. Hotsos White Paper.
http://www.hotsos.com.
Millsap, ., C. Shallahammer, and A. Adler. Predicting the Utility of the
Non-unique Index. Oracle Magazine Article, 1993. http://www.oramag.com.
Miracle A/S. Performance Tools, http://www.miracleas.dk.
Oracle Corporation. Multiple Articles and Notes related to performance monitoring
and tuning at Oracle Support Services - Metalink. http://metalink.oracle.com.
Oracle Technology Network. Oracle Documentation.
http://technet.oracle.com.
Oraperf, Inc., Online Performance Analyzer, http://www.oraperf.com
Shah, R. What is RAID ? - Details of this popular storage technology. Sun
Microsystems White Paper, 1999. http://www.sunworld.com/swol-06-1999/
f_swol-06-connectivity.html.
Shallahammer, C. Total Performance Management (An introduction to the method).
White Paper, 1995. http://www.orapub.com.
Shallahammer, C. Direct Contention Identification Using Oracle's Session Wait
Tables. White Paper, 2000. http://www.orapub.com.
Shome, P. Using Stored Outlines in OracleSi for Plan Stability. Proceedings of
Oracle Open World, 1999. http://www.oracle.com/openworld.
Sneed, B. Sun/Oracle Best Practices. White Paper, Sun Blueprints (TM)
Online-January 2001. http://www.sun.com/software/solutions/
blueprints/OlOl/SunOracle.pdf.
Vaidyanatha, G. Implementing RAID on Oracle Systems. White Paper,
Proceedings of the Oracle Open World 2000, 2000.
http://www.quest.com/whitepapers.
Vaidyanatha, G. Oracle Performance Management. White Paper, Proceedings of
the Oracle Open World 2000, 2000. http://www.quest.com/whitepapers.
Vaidyanatha, G. System Architecture for OracleS VLDBs - A Case Study. White
Paper, Proceedings of the Oracle Open World 1999, 1999.
http://www.oracle.com/openworld.
Wong, B. Configuring and Capacity Planning for Solaris Servers. Prentice Hall,
1997.
Wong, B. RAID: What does it mean to me? Sun Microsystems White Paper, 1995.
http://www.sunworld.com/sunworldonline/swol-09-1995/swol-09-raid5_p.
h- tml.


Oracle

,
.
Oracle ,
, SQL, .

.
:

,
SQL
Oracle
Oracle
Oracle
/ RAID Oracle
Solaris, HP-UX,
MX Windows NT
, ,
Oracle.

THE

5RN
REQUIRED READING lor the i

AUTHORIZE

Oracle Press
NS
O N L Y


www.lory-press.ru

A Division afTheMcGnav-HiuCompama

F R O M

5RNE

Вам также может понравиться