Nextextentprolems

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

SELECT

a.tablespace_name,
a.file_name,
a.bytes allocated_bytes,
b.free_bytes
FROM
dba_data_files a,
(SELECT file_id, SUM(bytes) free_bytes
FROM dba_free_space b GROUP BY file_id) b
WHERE
a.file_id=b.file_id
ORDER BY
a.tablespace_name;

#Script used to monitor datafiles close to their maximum size


#Threshold is number of extents away from the maximum datafile size
THRESHOLD=$1
LOGFILE=/tmp/datafile_extents_$ORACLE_SID.log
sqlplus -s apps/apps << EOF
set heading off
spool $LOGFILE
select distinct '$ORACLE_SID - Threshold for datafiles near max
extents'
from dba_data_files
where autoextensible='YES'
and trunc((maxblocks-blocks) /increment_by) <= $THRESHOLD
and increment_by != 0 ;
-- add data to logfile
select file_name, trunc((maxblocks-blocks) /increment_by)
from dba_data_files
where autoextensible='YES'
and trunc((maxblocks-blocks) /increment_by) <= $THRESHOLD
and increment_by != 0;
spool off
exit
CHAPTER 3 ¦ MONITORING AND TROUBLESHOOTING 71
EOF
RETURN_CODE=`grep "Threshold" $LOGFILE | wc -l`
if [ $RETURN_CODE -eq 0 ]
then
exit 0
else
exit 1
fi
If datafiles are near their maximum size, either the maximum size of the
datafile needs to be increased, or one or more datafiles need to be added to
the tablespace. The commands for both of these solutions were outlined in
the previous Identifying Tablespace Sizing Limitations section.
¦Caution Be aware of operating system limitations that are associated with large
files. If your filesystems can support large files, you can set each datafile to
have a maximum
size larger than 2GB. You should review and understand the limitations that may
be
associated with your flavor and version of UNIX. Some limitations you should rev
iew are
filesystem configuration options for supporting large files and limitations of c
ommands
that manipulate and move files, such as tar.
Identifying Maximum Extent Limitations
Even if plenty of space is available within the tablespace, errors can be
encountered due to an object reaching its maximum number of extents. To
monitor for objects at a threshold near the maximum number of extents, the
Applications DBA can use the following script:
#Script used to monitor objects that are close to
#their max number of extents
#Threshold is number of extents from the maximum
THRESHOLD=$1
LOGFILE=/tmp/max_extents_$ORACLE_SID.log
sqlplus -s apps/apps << EOF
set heading off
spool $LOGFILE
select distinct '$ORACLE_SID - Threshold for objects near max
extents'
from dba_segments
where max_extents - extents <= $THRESHOLD;
72 CHAPTER 3 ¦ MONITORING AND TROUBLESHOOTING
-- add data to logfile
select owner,
segment_name,
segment_type,
tablespace_name,
extents,
max_extents
from dba_segments
where max_extents - extents <= $THRESHOLD
order by extents DESC;
spool off
exit
EOF
RETURN_CODE=`grep "Threshold" $LOGFILE | wc -l`
if [ $RETURN_CODE -eq 0 ]
then
exit 0
else
exit 1
fi
To resolve this problem, you can alter the segment to increase the maximum
number of extents allowed. This can be achieved by executing the
following command:
alter [object_type] [object_name] storage (maxextents [number]);
In this command, [object_type] is either table or index, [object_name] is
the name of the object, and [number] is the maximum number of extents.
The following is a specific example of the alter statement that sets the
maximum number of extents to 500 for the table FND_USERS:
SQL>alter table FND_USERS storage (maxextents 500);
If the object is exhibiting fast growth, the extent size setting may be too
low. If this is the case, you may also set the maximum number of extents to
UNLIMITED, thus avoiding this error in the future. This is accomplished by
specifying UNLIMITED in the storage clause. The following is an example of
setting the maximum number of extents to UNLIMITED for the FND_USERS
tables:
SQL>alter table FND_USERS storage (maxextents UNLIMITED);

You might also like