BC505_ch11

advertisement
(C) SAP AG
BC505
10-1
Storage Management
Contents
 Storage management basics
 Monitoring freespace and space critical objects
 Internal and external fragmentation
 Reorganization
Objectives
At the end of this unit, you will be able to:
 Adapt storage parameters of tables and indexes
 Run and analyze the results of sapdba -check and sapdba -next
 Determine if a reorganization should be performed
 Perform a reorganization
 SAP AG 1999
(C) SAP AG
BC505
10-2
Space Management: Review
Table ABC
Tablespace
Segment
(table/index)
Index XYZ
Table DEF
Datafile2
Datafile1
Segment
192K
Segment
224K
Segment
192K
Extent
48K
1
Initial
Extent
Segment
256K
Segment
80K
...
Segment
192K
Segment
640K
...
...
Next
Extent
Extent
144K
8K
8K2 8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
8K
...
Disks
 File system
Data
block
Datafile1
Datafile2
 SAP AG 1999

Each table and index is assigned to a tablespace, which consists of one or more data files at the
operating system level. All table and index data is stored in the data files of the tablespace.

Oracle stores tables and indexes in individual data blocks. In an R/3 installation data blocks are 8 KB
in size. When new storage space is required for a table or index, one or more contiguous data blocks
of a data file are allocated to form an extent. If there is not enough contiguous freespace to allocate a
new extent, the Oracle error message ORA-1653 (for a table) or ORA-1654 (for an index) occurs.

Oracle data objects have several storage parameters that influence growth:
 The first extent (initial extent) should be large enough for the expected table or index size. If an
extent of a data object becomes full during an insert or update operation, the Oracle storage
management system attempts to allocate another extent in the tablespace.
 An object can allocate extents up to the limit MAXEXTENTS. If the maximum number of extents
per object is reached, the error message ORA-1631 (for a table) or ORA-1632 (for an index) is
displayed. If this occurs, you must increase the parameter MAXEXTENTS and check the size of
the table's NEXT parameter.
 PCTFRE, PCTUSED, and PCTINCREASE are three additional storage parameters. Only change
them under special circumstances and after consulting SAP for support.
(C) SAP AG
BC505
10-3

Depending on the size of each data record, several data records can be stored in an 8 KB data block.
For fields of indexes and for long raw fields, Oracle compresses the contents of each data record. As
a result, the data records of an index or a table with one or more long raw fields will usually differ in
length.

When a data record is deleted, a gap of unused storage space results within the corresponding data
block. The existence of such gaps within data blocks is called internal fragmentation. Oracle can
reorganize internally fragmented data blocks so that wasted storage space is re-used.

The extents, which belong to the different data objects of a tablespace, allocate storage space within
data files of this tablespace. When a database object is dropped, the extents are released. Gaps of
unused storage space result. The existence of one or more of these gaps is called external
fragmentation of a tablespace. Newly allocated extents can only be inserted into such a gap if they
are smaller than or equal to the size of the gap.

If the NEXT extent size of an object is larger than the largest free contiguous storage area of its
tablespace, it is called a space critical object. The allocation of a new extent for this object will fail if
you have not extended the tablespace.
(C) SAP AG
BC505
10-4

Use the R/3 tool SAPDBA with the option -check to check the following:
 Extents of tables and indexes
 Tablespace filling
 Physical consistency of the database. That is, the consistency of the control files, redo log files,
and data files
 Severe error messages in the alert log
 init<SID>.ora parameter settings
 Database problems specific to the R/3 environment

Schedule SAPDBA -check to run daily during periods of low system activity, by using either the
DBA Planning Calendar (Transaction DB13) or by entering command sapdba -check at the
command prompt.

Command sapdba -check generates a log file called <DateTime>.chk. which is written to
directory ../../sapcheck. The log information is also written to the database table DBMSGORA, and
can be viewed using the R/3 Database System Check Monitor (Transaction DB16). This log
information should be monitored after each SAPDBA -check run.

If a database or system error occurs, use command sapdba -check to check the log information.

To monitor your sapdba -check run, you can also use Transaction DB24.
(C) SAP AG
BC505
10-5

To configure the checks performed by SAPDBA -check, choose Tools >> CCMS >> DB
administration >> Check >> Configuration (Transaction DB17).

The system checks are identified by an error type and name (Err Type, Parameter ID):
 DBA: The checks that report these errors are programmed into SAPDBA. You can change the
thresholds specified for these checks. You can activate and deactivate these checks.
 ORA: Oracle alert-log messages (important administrative and error messages) that the R/3
System check will report to you. You can add additional “ORA”-entries.
 PROF: Problems in the Oracle init<SID>.ora initialization profile. You can add additional
parameters.

The columns in the configuration table DBCHECKORA mean the following:
 Active: Activate (Y) or deactivate (N) the check for the problem
 Severity: Warning (W) or error (E). Errors require immediate attention.
 Check Oper, Check Val, Check Unit: The threshold value for triggering a warning are defined in
these columns. For example, Check Oper >, Check Value 80, and Check Unit P indicates that a
warning or message should be triggered when the database value exceeds 80 percent.
 CorrMeasure: This provides a quick, editable tip for solving the problem. If these fields are empty,
first analyze the problem in detail, and then choose a measure to correct it.
(C) SAP AG
BC505
10-6
Tablespace Extension
ADD A DATA FILE:
File size depends on the estimated increase of the
tablespace objects. Check for the number of data
files in the database.
RESIZE THE DATA FILE:
Extend the size of the data file depending
on the space available on the file system
and size of critical object.
New file
<tablespace>.data1
<tablespace>.data1
<tablespace>.data2
Critical object
Critical object
OR
Extents
Original size
After Resize
Back up extended
tablespace and control files
 SAP AG 1999

If the database tries to allocate another extent but finds that there is no more freespace in the
corresponding tablespace, the SQL operation fails. The available storage space of a tablespace can be
extended in online operation by adding another data file.

To add a data file, use the SAPDBA. Select c -Tablespace administration.
 Specify the name of the tablespace to be extended in the submenu a - Tablespace
 In the submenu f - Alter tablespace <tablespace name> add data file default recommendations for
file name and data file size are already given. Adapt them according to your requirements.
 Select s - Start to start the Add data file action. SAPDBA performs a check on the available
storage space in the specified file system before the data file is added.
 SAPDBA continues with the backup menu and asks you to back up the extended tablespace.
Backing up the extended tablespace ensures that the new state of the database can be recovered.
SAPDBA stores the old version and the new version of the control file in directory
sapreorg/<timestamp>. The action log <timestamp>.ext is written to directory sapreorg.

To resize a data file, use SAPDBA. Select d - Reorganization.
 Then select option h - Resize data file of a tablespace.
 Specify the name of the tablespace to be extended in the submenu a - Tablespace
 Select s - Start to start the resizing process. SAPDBA gives a list of data files, from which you can
select which data file you want to resize. In the submenu b - New size default recommendations for
the data file size are already given. Adapt them according to your requirements and select s - Start
and execute changes. SAPDBA performs a check on the available storage space in the specified
file system before the data file is resized. It also writes a log file with <timestamp>.rrs name in
the sapreorg directory.
(C) SAP AG
BC505
10-7
Storage Categories of SAP Database Objects
R/3
ABAP Dictionary: Display technical settings
Name
Short text
Last changed
Status
x
ZPROGRAM
Transparent Table
Test Table for technical settings
TND
24/08/1999
Active
Saved
Logical storage parameters
Data class
APPL1
Size category 4
Transaction data. transparent tables
Data records expected: 39.000 to 3.100.000
Table TGORA (storage parameters for R/3 tables)
Category INIT
NEXT MINEXTENT MAXEXTENT
0
16
40
1
300
1
16
160
1
300
2
16
640
1
300
3
16
2560
1
300
4
16
10240
1
300
5
16
20480
1
300
6
16
40960
1
300
7
16
81920
1
300
8
16
163840
1
300
9
16
327680
1
300
10
16
655360
1
150
11
16 1310720
1
150
12
16 2621440
1
150
13
16 5242880
1
150
14
16 10485760
1
150
Table IGORA (storage parameters for R/3 indexes)
Category INIT
0
16
1
16
2
16
3
16
4
16
5
16
6
16
7
16
8
16
9
16
10
16
11
16
12
16
13
16
14
16
NEXT MINEXTENT MAXEXTENT
40
1
300
80
1
300
160
1
300
640
1
300
2560
1
300
5120
1
300
10240
1
300
20480
1
300
40960
1
300
81920
1
300
163840
1
150
327680
1
150
655360
1
150
1310720
1
150
2621440
1
150
 SAP AG 1999

Default values are used for INITIAL, NEXT, and MAXEXTENT when creating an SAP table or
index during installation of an R/3 System. These defaults are derived from the objects category.

The category assignment for each R/3 table and index is a technical setting. You can access the
technical settings of R/3 tables and indexes using the viewing (SE12) and editing (SE11) transactions
for ABAP Dictionary objects.

The INITIAL, NEXT, and MAXEXTENT values used for a specific category are defined in table
TGORA for R/3 tables and in IGORA for R/3 indexes.
 NEXT sizes range from 40 KB, for tables in category 0, to 20971520 for tables in category 14
 The NEXT size for a category is either twice or four times the size of the NEXT size for the
previous category. This helps to prevent external fragmentation.
 The MAXEXTENT for R/3 tables and indexes is usually set to 300. If the number of extents for a
database object approaches 300, you must increase this parameter. As of Oracle release 7.3, you
can set this parameter to UNLIMITED.

Uncontrolled growth of the number of extents present in the database can increase the number of
displacements in the Oracle shared pool. Because it is essential to limit the growth of the extents, we
do not recommend setting the MAXEXTENT to UNLIMITED for all objects. The growth of an
object, such as a table, index, or rollback segment is determined by the size specified in parameter
NEXT.
(C) SAP AG
BC505
10-8

The SAPDBA option -next allows you prevent uncontrolled extent growth for all database tables and
indexes. The size of parameter NEXT for all R/3 database objects is calculated according to the
following algorithm:
 The storage space allocated for the database objects (in KB) is determined and divided by 10. This
value is compared to the current setting for NEXT. The larger of the two values, which is called
the “NEXT candidate”, is used to perform the following comparisons:
 The NEXT value derived from the technical settings of the object is used if it is larger than the
NEXT candidate
 If it is not, the next smaller value found in TGORA or IGORA is used if it differs by not more than
5 blocks from the NEXT candidate
 If it does not, the next larger value found in TGORA or IGORA is used
 If no larger value is found in TGORA or IGORA, parameter NEXT is set to the value of the
NEXT candidate

Schedule SAPDBA -next using the R/3 CCMS Planning Calendar. Schedule SAPDBA -next to run at
least once a week, and after major database changes. The action log is written to file
<timestamp>.nxt in the directory ../../sapcheck.

It may be the case that not enough contiguous storage space is available to allocate a new extent for
tables that have an increased setting of parameter NEXT. After each SAPDBA -next run, you must
check for space critical objects in the database.
(C) SAP AG
BC505
10-9
Daily Monitoring: Tables and Indexes
Database System
Database ORACLE
Name TCC
Date/time of this analysis 08/24/1999 07:01:30
Refresh
Refresh
Checks
Checks
Space
Space statistics
statistics
Tablespaces
Total number
27
Total size/kb
12.123.016
Total free/kb
3.050.320
Minimum free/kb
4.024
Max. autoextensible/kb AutoExtend off
Tables and indexes
Total number
Total size/kb
More than 1 extent
Missing in database
Missing in R/3 DDIC
Space-critical objects
Tables
13.064
5.915.664
1.082
0
0
0
Current
Current sizes
sizes
Space
Space statistics
statistics
25%
Indexes
15.305
2.979.432
1.591
1
0
0
Freespace
Freespace statistics
statistics
Detailed
Detailed analysis
analysis
Missing
Missing indexes
indexes
Space
Space critical
critical objects
objects
Space
Space statistics
statistics
Maintain table: TCOLL
Day
Time
M T W T F S S
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
------------------------------------------------------------------------------RSDBPREV 1
C
X:X:X:X:X:X:X
X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X
RSORATDB 1
C
X:X:X:X:X:X:X
: : : : : : :X: : : : : : : : : : :X: : : : :
 SAP AG 1999

To perform a detailed analysis of storage related issues, use the Tables and Indexes Monitor
(Transaction DB02).

The Tables and Indexes Monitor has three levels of resolution: Database level, Tablespace level, and
the Tables and Indexes level. In any one of the generated views, double-click the line of an object to
display the elements of the object. From the lowest level, that is from the Tables and Indexes level,
you can access a history view for this object. Navigating to higher levels of resolution works for
most of the available views.

The ABAP report RSORATDB collects the data required for the Tables and Indexes Monitor and
stores it in the database table MONI. The contents of this table are evaluated when the Tables and
Indexes Monitor is displayed. To refresh the values, choose Refresh.

To set the frequency of the execution of report RSORATDB (and other reports relevant for
monitoring) maintain table TCOLL using Transaction SM31. Also schedule job
COLLECTOR_FOR_PERFORMANCEMONITOR to run hourly within your production system.
For further information, see R/3 Notes 12103 and 16083.

The Oracle autoextend option is supported in R/3 Release 4.5B and higher.
(C) SAP AG
BC505
10-10
Tables and Indexes: Important Reports
Critical growth of tables/indexes in the last 4 weeks
09/05/1999 10:40:26
DB_SERVER
Critical table/index growth
Intervals: 08/06/1999 - 09/05/1999
Table Name
ATAB~0
SMENINTT~
SKAT~001
Type
INDEX
INDEX
INDEX
Size(KB)
Total
72.720
2.416
9.960
Measurements:
NextExtSize
Growth (Kbyte)
10.880
160
2.400
80
2.080
80
29
Extents
Total Growth
168
68
31
30
89
26
MaxExtents
defined %used
300
56
300
10
300
30
FirstExtent
(Kbyte)
45.936
16
2.904
Tablespace
PSAPPOOLI
PSAPSTABI
PSAPSTABI
Table Space History
09/05/1999 10:40:26
DB_SERVER
Intervals: 08/06/1999 - 09/05/1999
Measurements: 30
Scale: Day
Scale: Day
Size (KB)
Free(KB)
Used (KB)
%-Used
Tablespace
Total
Chg/day
Total
Total
Chg/day Total Chg
PSAPPOOLD
747.512
0
38.944
708.568
2.415
94
0
PSAPPOOLI
563.200
0
97.888
465.312
1.793
82
0
PSAPSTABI
921.600
0
70.288
851.312
1.909
92
0
PSAPSTABD
1.013.744
0
31.024
982.720
3.384
96
0
PSAPROLL
307.200
0
182.392
124.808
3.084
40
1
PSAPBTABD
735.216
0
231.336
503.880
1.249
68
0
PSAPBTABI
409.600
0
125.768
283.832
157
69
0
PSAPSOURCED
102.400
0
69.296
33.104
6
32
0
PSAPSOURCEI
102.400
0
47.520
54.880
3
53
0
PSAPTEMP
307.200
0
307.192
8
36
0
0
PSAPUSER1D
8.192
0
4.024
4.168
36
50
0
PSAPPROTI
33.792
0
16.592
17.200
52
50
0
Tables/Indexes
Total Chg/day
6.619
0
6.751
0
4.404
0
3.325
0
15
0
2.344
0
3.222
0
47
0
54
0
0
0
4
0
114
0
Extents
Total Chg/day
8.692
22
9.296
21
6.156
10
4.307
8
120
3
2.471
1
3.542
1
49
0
60
0
0
0
4
0
131
0
 SAP AG 1999

To display a list of objects with the strongest growth of extents or with more than 80% of
MAXEXTENTS allocated, call Transaction DB02, and choose Checks >> Check next extent size. To
display a history view for a single table or index, double-click a line describing an object and choose
History per weeks.

To monitor the size, free space, and usage of storage space for all tablespaces, choose Space
statistics from the tablespace section. To display the history of a specific tablespace, double-click the
tablespace line. Daily, weekly, and monthly histories are available.

To display a detailed analysis of the current storage usage of a table or an index, choose Detailed
Analysis from the tables and indexes section, and enter a name of a table or index. You can also
specify the name of a tablespace to display a list of its elements.

To analyze critical storage-related problems, choose Space critical objects.

To display a list of indexes that are defined in the R/3 Data Dictionary but do not exist on the
database, choose Missing indexes in the Tables and indexes section.
(C) SAP AG
BC505
10-11
Analyzing Internal Fragmentation
sapdba -analyze
DB02
>> Detail Analysis
SAPDBA Detail Log
Detail log: 9908221023.aly
***********************************************************************
(12690 tables analyzed - sorted by empty space in descending order)
TABLESPACE_NAME
TABLE_NAME EMPTY(kb) NEVER_BEEN_USED(kb) USED(kb)
Detailed analysis for Index ATAB~0
PSAPSTABD
E071K
42032
42032
5128 Data from DBA_SEGMENTS/DBA_INDEXES
PSAPEL40AD
D010L
31112
31112
3168
Space
PSAPPOOLD
ATAB
17112
17112
58368
72.720
PSAPES40AD
DOKCLU
13136
13136
323448 Allocated space..Kbyte
blocks......
9.090
PSAPES40AD
D010S
10088
10088
774848
***********************************************************************
extents.....
168
CHARTS OF 20 EMPTY INDEXES - USING: VALIDATE STRUCTURE
(6751 indexes analyzed. sorted by empty space within BTREE =
Block structure
USED_BY_BTREE - USED)
8.192
TABLESPACE_NAME
INDEX_NAME
TOTAL(kb)
USED_BY_BTREE(kb) USED(kb) Blocksize.........byte
PSAPPOOLI
PSAPPOOLI
PSAPPOOLI
PSAPPOOLI
ATAB~0
T512T~0
RTXTL~0
T800Y~0
72720
7280
11920
8800
72648
7200
10072
8744
50563
4641
7745
6726
Pct_free..............
Transactions initial..
maximum..
Header minimum....byte
Data maximum......byte
10
2
255
159
7.230
Process freelists.....
Freelist groups.......
1
1
 SAP AG 1999

The SAPDBA option -analyze provides information about the storage allocation for a table or an
index. You can use it to determine the degree of internal fragmentation of the database object, and to
analyze a single table using SAPDBA.

To display the logs of the SAPDBA actions performed to refresh the optimizer statistics, use the
DBA Operation Monitor (Transaction DB24). To display only the action logs of SAPDBA -analyze,
choose Function IDs (function ID aly).

USED space is storage space consumed by the table or index contents. EMPTY is the difference
between storage space allocated for a table and USED space.

NEVER_BEEN_USED space is storage space that has been allocated for a table but has not yet been
used by the table. USED_BY_BTREE is the storage space allocated by the B*tree.

In the sapdba -analyze detail log, check for:
 Tables that have a large difference between EMPTY and NEVER_BEEN_USED. This difference
indicates internal fragmentation of a table.
 Indexes that have a large difference between USED_BY_BTREE and USED. This difference
indicates internal fragmentation of an index.

The Tables and Indexes Monitor (Transaction DB02) provides detailed information about tables and
indices. Call Transaction DB02, choose Detailed Analysis and, in the dialog box displayed, specify
the name of the object you want to analyze. Select the object and choose Detail Analysis. Block level
details for that object are then displayed.
(C) SAP AG
BC505
10-12
Reorganization: Basics
Example for a table reorganization
Example for an index recreation
1) Export table
1) Drop index
Data_1
Data_1
2
1
0
2
2
1
0
1
0
2
1
0
2) Recreate index
sapreorg
2) Drop table
Additional storage
space required
PSAPTEMP
Data_1
0
Data_1
2
1
0
0
2
3) Import table
1
0
Recreate index
 SAP AG 1999

To eliminate storage-related problems, perform a reorganization. The objects that can be reorganized
include tables, indexes, and data files of the database.
 After a table or index is reorganized, block usage for the reorganized object is optimal. Extents can
be merged together to reduce the number of extents present in the database. Storage space required
for the object can also be minimized.
 When data files of a tablespace are reorganized, some data files are merged together. This means
the number of data files present in the database can be minimized.

To perform a reorganization, additional storage space is required to store intermediate data. This
storage space is either required in the database or in directories created for this purpose. Intermediate
data can also be stored on tape. SAPDBA tries to forecast the amount of additional storage space
required. When a reorganization is performed, bottlenecks can occur in the following areas:
 The data files of the tablespace where the reorganized object resides. Typical error: No data file
has enough freespace to hold the new larger extents or a temporary second copy of the object.
 The directory sapreorg. Typical error: This directory is too small to hold the export sets
 The tablespace PSAPTEMP. Typical error: This tablespace is too small for an index recreation

If an error occurs during a reorganization, data can be lost. If a valid and up-to-date data backup
exists, the risk of data loss is minimized. After the data files of a tablespace have been reorganized
successfully, you must immediately perform a backup.
(C) SAP AG
BC505
10-13

Reorganizing physical data objects is costly, both in terms of time and resources, and should be
performed only in exceptional cases. To minimize the need for reorganizations, monitor the database
regularly.

The R/3 System is not available during a reorganization. Therefore, reorganize physical data objects
for the following reasons only:
 Disk hot spots: Unfavorable physical distribution of tables, indexes, or data files results in nonuniform distribution of disk accesses on available disks
 Heavily fragmented indexes: Fragmented indexes can affect performance. Fragmented tables will
only affect performance in special cases (check for R/3 Notes indicating this problem).

To avoid having to perform reorganizations:
 Run sapdba -next weekly to adapt the storage parameters of all tables and indexes. This prevents
database objects from allocating a high number of extents. If a table has a high number of extents,
change the parameters NEXT and MAXEXTENTS. Do not perform a reorganization.
 Try to estimate growth of a critical tablespace before extending it with a data file of an appropriate
size. Use SAP archiving to archive obsolete data. This prevents the number of files in your
database system from approaching the limit DB_FILES. If there is a high number of data files, try
to increase the parameters MAXDATAFILES (number of files your OS can handle) and
DB_FILES. Do not reorganize a tablespace.
(C) SAP AG
BC505
10-14
Reorganization: Phases and Types
Phases
 Create script and restart file
Check the free space
 Perform a reorganization
Directories
sapreorg/<timestamp>/<timestamp>.<extension>.
sapreorg, PSAPTEMP.
PSAPROLL, objects tablespace
Reorganization of a single
object or a list of objects
Reorganization of a tablespace
Data file_1
2
0
2
1
0
2
0
6
3
2
3
4
0
1
0
3
4
1
0
1
2
2
1
0
0
0
4
1
0
4
1
0
2 5
1
Data file_2
8
5
1
3
0
4
3
3
Data file_new
Data file_1
0
5
0
Reorganization of a tablespace with data files
2
0
0
2
0
4
Internal and external fragmentation
Fragmented indexes
Disk y
0
4
3
11
5
0
Moving / Renaming data files
1
2
7
1
Disk "hot spots"
Fragmented indexes
Internal fragmentation
Disk x
Data file_2
0
6
5
1
Data file_1
7
8 9 10
0
2
1
0
1
Data file_2
Data file_1
Data file_1
6
9
0
0
10
7
1
0
0
11
5
0
4
Disk "hot spots"
 SAP AG 1999

SAPDBA reorganizations are performed in two phases:
 In phase one, the SQL script for the reorganization process is created in the subdirectory
<timestamp> of the working directory. The file restart.<extension> is created in this subdirectory
to enable a restart of the reorganization (first eliminate the cause of the error). Reversible actions
can be reset. SAPDBA checks if there is enough storage space available to perform the
reorganization.
 In phase two, the reorganization script is executed. (Action log name: <timestamp>.<extension>)

Reorganization of a single object (table or index): Use this function to eliminate internal
fragmentation, to reduce the number of extents allocated for a table or index, and to move a table or
index to another tablespace in order to eliminate a disk hot spot (extension rsi)

Reorganization of a list of objects: Use this function to reorganize a group of several objects. An
ASCII file must be created in the working directory with the required list of objects. (extension rli)

Reorganization of a tablespace: Use this function to reorganize all objects belonging to this
tablespace. The directory and file structure of the tablespace will remain unchanged. (extension rtc)

Reorganization of a tablespace with data files: Use this function to change the data file structure and
to reorganize the objects contained in the tablespace. The number of data files existing in the
database can be minimized. (extension rtd)

Moving and renaming data files: Use this function to move files to another disk. This is not classified
as a reorganization because the action is performed on file level (extension rmv).
(C) SAP AG
BC505
10-15
Reorganization: Methods
Reorganization
Reorganizationof
ofindexes
indexes
Method
Runtime
Method
Runtime Security
Security Additional
Additionalspace
space Parallel
Parallel
Alter
index
++
++
Objects
tablespace
II
Alter index
++
++
Objects tablespace
rebuild
PSAPTEMP
rebuild
PSAPTEMP
Index
Index
recreate
recreate
++
++
PSAPTEMP
PSAPTEMP
II
Reorganization
Reorganizationofoftables
tables
Method
Runtime
Method
Runtime Security
Security Additional
Additionalspace
space R3Chop
R3Chop Parallel
ParallelCompress
Compress Restrictions
Restrictions
Create
table
++
++
Objects
tablespace
NA
T
NA
No
Create table
++
++
Objects tablespace
NA
T
NA
Notables
tableswith
with
as
select
PSAPROLL
LONG/RAW
as select
PSAPROLL
LONG/RAWfields
fields
SAPDBA
unload.
+
+
sapreorg
NO
P
NO
export
<
max_file_size
SAPDBA unload.
+
+
sapreorg
NO
P
NO
export < max_file_size
SQL*loader
PSAPTEMP
(usually
SQL*loader
PSAPTEMP
(usually22Gbyte)
Gbyte)
Oracle
Oracle
export/import
export/import
oo
++
sapreorg
sapreorg
PSAPTEMP
PSAPTEMP
YES
YES
PP
YES
YES
Legend:
Legend:
++
++ == very
very good,
good, ++ == good,
good, oo == average,
average, NA
NA == Not
Not applicable
applicable
II == Parallel
Parallel on
on index,
index, TT == Parallel
Parallel on
on table.
table. (Oracle
(Oracle PARALLEL
PARALLEL clause)
clause)
P
P == Parallel
Parallel on
on process
process level
level (SAPDBA
(SAPDBA creates
creates several
several processes)
processes)
 SAP AG 1999

There are two methods to export and import table data. In both cases, because tables are dropped
before they are recreated, data may be lost :
 export / import uses Oracle EXPORT and IMPORT commands. Additional storage space for the
export dump is required in directory sapreorg and in PSAPTEMP (index recreation).
 SAPDBA unload / load uses either the tool SAPDBA LOAD or the Oracle SQL*loader. Additional
storage space for the LOAD file is required in directory sapreorg and in PSAPTEMP (index
recreation).

The following methods do not require the export and import of database data:
 Create table ... as select: SAPDBA first generates the table to be reorganized with the new
parameters under a new name (by adding the character #). The data is copied directly from the old
table to the new. The old table is dropped and the new table is renamed. This option cannot be
used for tables with LONG columns or for reorganizing tablespaces with data files. Additional
storage space is required as the table temporarily exists twice in the same tablespace. Enough
space must be available in PSAPROLL to hold rollback information.
 Alter index / Rebuild: The index is first rebuilt in tablespace PSAPTEMP using the existing index.
Then it is copied into the corresponding tablespace. The old index is dropped and the optimized
index is activated. Table and index are locked during this process. Additionally required storage
space can be up to twice the size of the index.
 Recreate index: The index is dropped and recreated. Storage space is required in PSAPTEMP.
(C) SAP AG
BC505
10-16

To define a reorganization, you can specify the following options:
 Compress extents = Yes. SAPDBA merges the extents occupied by the table or index to one
extent. If this option is not used, the extents are allocated using the current storage parameters of
the object. Adjacent free storage fragments in the entire tablespace are merged.
 Reduce object size = Yes. SAPDBA automatically tries to reduce the size of the objects (allocated
storage space) during the reorganization for an export or import. To determine the actual storage
space occupied, SAPDBA uses the Oracle ANALYZE command. Script generation requires a
specific amount of time and locks the tables to be reorganized.
 Chop = Yes. SAPDBA sends the exported data to the chop tool through a named pipe. The chop
tool then splits the export data into several files. This option is only available if parameter
chop_util_name is entered in the profile init<SID>.dba. This option is not available for Windows
NT. If the export dump files are larger than the maximum file size (usually 2 GB) for the operating
system, use this option.
 Compress = Yes. The export dump is compressed using OS facilities (not for dump to tape).
 Parallel export/import: The export and the import are distributed to several parallel processes. The
init<SID>.sap parameter exp_imp_degree determines the maximum number of processes that are
created for the reorganization. The number of directories and/or tape devices specified for the
export dump files also limits the number of processes created.
 Oracle PARALLEL clause: The reorganization is accelerated with the help of the Oracle
PARALLEL QUERY functionality.
(C) SAP AG
BC505
10-17
Unit Summary
Now you are able to:

Explain the concepts of Oracle storage management

Name the problems of data storage

Monitor and avoid problem situations

Solve storage related problems efficiently
 SAP AG 1999

In an Oracle database, the way physical hard disk space is allocated for a table or index is controlled
by the objects storage parameters. Storage parameters that are set incorrectly can lead to unwanted
growth behavior.

The following R/3 System tools provide you with an effective means of preventative monitoring, and
should be used to avoid uncontrolled database growth:
 The SAPDBA checks the database for possible storage related problems
 You can extend the database using the SAPDBA
 The SAPDBA adapts storage parameters of growing objects to optimize growth behavior
 The SAPDBA provides comprehensive support for the reorganization of Oracle database objects
 You can monitor the current status of the database using the CCMS Database Monitors (DB02,
ST04, DB24).

You can limit growth of the database by archiving obsolete data. R/3 provides you with the required
archiving functionality.
(C) SAP AG
BC505
10-18
Unit Actions
?
 Exercises
 Solutions
 SAP AG 1999
(C) SAP AG
BC505
10-19
Storage Management: Exercises
No.
Exercise
1
Use sqlplus to run the script createtab.sql, which is located in directory
scripts:
Log on as user ora<SID>. If the database is not open, open it using
SAPDBA. Switch to directory scripts. Start sqlplus. Log on to the
database as user SAPR3 with password SAP. Start the script
createtab.sql by entering the sqlplus command line @createtab.sql
2
Run sapdba –check on your database.
2.1
Check the log file of sapdba –check for messages regarding table
BC505CHECK and index BC505CHECK~0.
3
Adapt the storage parameters of table BC505CHECK using SAPDBA.
Ensure that the new MAXEXTENTS value is larger than number of
extents currently allocated + 30%. Do not use the SAPDBA
recommendation for NEXT, but set it back to the current value.
3.1
Run sapdba –check again. Explain the difference in the log files of the
sapdba –check runs before and after you adapted MAXEXTENTS of
table BC505CHECK
4
Use SAPDBA to automatically adapt the NEXT extent sizes for all SAP
tablespaces.
4.1
Check for problems in the sapdba –next log.
4.2
Run sapdba –check again and check for problems in the log file. Why
should you always run sapdba –check after a sapdba –next?
5
Solve the problems found for tablespace PSAPUSER1D by adding a
new data file (1MB in size).
5.1
Solve the problems found for tablespace PSAPUSER1I by adding a new
data file (200KB in size).
5.2
Check for problems in the sapdba –check log. Explain what happened
to the entries for table BC505CHECK and index BC505CHECK~0.
6
Why is it important to run a backup after you have changed the file
structure?
7
Check for internal fragmentation of tablespace PSAPUSER1D
7.1
Using ”estimate sample 10 percent”
7.2
Using ”compute statistics / validate structure”
7.3
Check the log files of the analyze actions. What is the difference
between both methods?
8
Reorganize the index tablespace PSAPUSER1I using Alter Index
Rebuild, the storage options compress extent and reduce object size
(compute), and hide the table during reorganization.
8.1
Check the log file of the reorganization.
9
Reorganize tablespace PSAPUSER1D including the data files, using the
SAPDBA unloader / ORACLE SQL*loader, with option reduce object
size, reduce data file size (accept the default).
(C) SAP AG
BC505
10-20
9.1
Check the log file of the reorganization.
10
Optional: Reorganize tablespace PSAPUSER1D including the data files
using the Oracle export/import, reduce object size by compute, hide
table during reorganize.
10.1
Check the log file of the reorganization.
11
Optional: Run script extent.sql from SQL*Plus to create an extent
problem in tablespace PSAPUSER1D. Now execute the script
extent_run.sql. Analyze the error message.
11.1
Correct the error and try to successfully complete the script
extent_run.sql.
12
Optional: Run script ts_over.sql from SQL*Plus. Analyze the error
message.
12.1
Solve the problem.
(C) SAP AG
BC505
10-21
Storage Management: Solutions
No.
Solution
1
2
As user ora<SID>, issue command sapdba –check.
2.1
After SAPDBA has finished, switch to directory sapcheck and look for
the file <timestamp>.chk. Edit the file (using command more <check
file name>, and use the spacebar to go to the next page). The
following messages are displayed:
SEGMENT_MANY_EXTENTS : BC505CHECK
TABLESPACE_FULL : BC505CHECK~0
(This problem will be solved later)
3
Start SAPDBA, and choose: d – Reorganization  b - Alter/show table
or index storage parameters  b - Specify table name BC505CHECK 
s - Alter/show parameters  b - NEXT, enter current value  d –
MAXEXTENTS, enter new value  s – commit.
3.1
After SAPDBA has finished, switch to directory sapcheck and look for
the file <timestamp>.chk. Edit the file (using command more <check
file name>). The following message should no longer be displayed:
SEGMENT_MANY_EXTENTS : BC505CHECK
4
Run sapdba –next PSAP%. Then run sapdba –check again.
4.1
After SAPDBA has finished, switch to directory sapcheck and look for
the file <timestamp>.nxt. NEXT for BC505CHECK has been changed by
sapdba –next.
4.2
BC505CHECK now is reported as a critical object because
PSAPUSER1D is too small to hold a NEXT extent of this table. As
sapdba –next can increase the NEXT size of tables or indexes, it is
possible, that the larger NEXT extents will not fit into the tablespace
anymore. Run sapdba –check to detect these problems.
5
Start SAPADBA and choose: c - Tablespace administration  a –
Tablespace, enter PSAPUSER1D  f – Alter tablespace PSAPUSER1D
add data file  c – New size, enter 1M  s – Start.
You can skip the backup action recommended by SAPDBA.
5.1
Start SAPADBA and choose c - Tablespace administration  a –
Tablespace, enter PSAPUSER1I  f – Alter tablespace PSAPUSER1I
add data file  c – New size, enter 200KB  s – Start
You can skip the backup action recommended by SAPDBA
5.2
As PSAPUSER1D/PSAPUSER1I now are large enough to hold a NEXT
extent of BC505CHECK/ BC505CHECK~0, the critical object entries are
no longer displayed.
6
You should always save the extended tablespace and the new version
of the control file after the extension so that the complete recovery
functionality of the SAPDBA is available (partial restore and complete
recovery). To do this, you can use, for example, the SAP tool
(C) SAP AG
BC505
10-22
BRBACKUP. For this reason, after a tablespace extension, SAPDBA
automatically branches to the backup database menu to enable you to
immediately start the appropriate backup.
7
7.1
Run command sapdba –analyze PSAPUSER1D -method EE –option
P10
7.2
Run command sapdba –analyze PSAPUSER1D -method CI
7.3
Log files are written in directory sapcheck.
The log file name of an analyze action is <timestamp>.aly.
For the estimate method, empty and never_been_used always have the
same value.
For the compute statistics/validate structure method, the values for
empty and never_been_used differ, as this method is more accurate.
8
Start SAPDBA and choose d – Reorganization  e – Reorganize
tablespace  a – Tablespace, and enter PSAPUSER1I. Then choose g –
Storage parameters  d – Reduce object size. Choose a to toggle to
compute option  q – Return  h - Object handling  a – Hide tables
during reorg  c – Rebuild indexes  q – Return  s – Start.
After generating a script, start the script immediately using option 1.
8.1
Check the file <timestamp>.rtc in directory sapreorg.
9
Start SAPDBA and choose d – Reorganization  f – Reorganize
tablespace and data files  a – Tablespace, and enter PSAPUSER1D.
Then choose f – ORACLE exp/imp. Then choose b to toggle to Unload /
load  q – Return  g – Storage parameters  d – Reduce object size
 q – Return  h – Object handling  d – Reduce data file size (use
10% default)  q – Return  s – Start.
After generating a script, start the script immediately using option 1.
9.1
Check the file <timestamp>.rtd in directory sapreorg.
10
Start SAPDBA and choose d – Reorganization  f – Reorganize
tablespace and data files  a – Tablespace, and enter PSAPUSER1D.
Then choose g - Storage parameters  d – Reduce object size. Then
choose a to toggle to compute option  q – Return  q – Return  h Object handling  a – Hide tables during reorg  q – Return  s –
Start.
After generating a script, start the script immediately using option 1.
10.1
Check the file <timestamp>.rtc in directory sapreorg.
11
Change to directory /<ORACLE_HOME>/scripts, start SQLPLUS, log on
as user SAPR3, and run @extent.sql. Now execute the script
extent_run.sql. A MAXEXTENT problem is displayed for table BC505EX.
11.1
Increase parameter MAXEXTENTS for table BC505EX. (see exercise 3)
12
Change to directory /<ORACLE_HOME>/scripts, start SQLPLUS, log on
as user SAPR3, and run @ ts_over.sql. A tablespace overflow will be
displayed for tablespace PSAPUSER1D.
12.1
Add a data file to tablespace PSAPUSER1D (see exercise 5)
(C) SAP AG
BC505
10-23
(C) SAP AG
BC505
10-24
Download