Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 









Monitor Tablespace Tips

Oracle Database Tips by Donald Burleson

The DBA needs to monitor more than just users. Tablespaces also require watching, because they are not unchanging objects. They are subject to becoming filled and/or fragmented. The Oracle Administrator toolbar provides for a GUI-based monitoring of tablespaces via the Storage Manager (see Figure 11.4). Unfortunately, it provides no report output. Luckily, it is a fairly easy thing to monitor tablespaces using the V$ and DB_ views. Look at Figure 11.5, which shows the DBA_ views that relate to tablespaces, as we examine a script or two that provide us with information we can put our hands on.

Figure 11.4 Oracle Enterprise Manager Storage Manager screen.

Figure 11.5 DBA_TABLESPACES view cluster.

Monitoring Tablespace Freespace and Fragmentation

Let's begin by examining a report that covers two critical parameters, available space and fragmentation. The OEM GUI includes a tablespace map feature that gives this information graphically and can be printed in a report format; this is shown in Figure 11.6. An example of the OEM tablespace analysis report is shown in Figure 11.7. For a manual report, see Source 11.14.

Figure 11.6 OEM tablespace map.

Figure 11.7 OEM tablespace analysis report.

SOURCE 11.14 A report on tablespace space usage and fragmentation.

rem Name:     free_space.sql
rem FUNCTION: Provide data on tablespace extent status
rem FUNCTION: this report uses the free_space2 view
rem FUNCTION: includes fsfi from DBA Handbook
set pages 58 LINES 132
COLUMN tablespace      HEADING Name             FORMAT a30
COLUMN files           HEADING '#Files'         FORMAT 9,999
COLUMN pieces          HEADING 'Frag'           FORMAT 9,999
COLUMN free_bytes      HEADING 'Free|Byte'      FORMAT 9,999,999,999
COLUMN free_blocks     HEADING 'Free|Blk'       FORMAT 999,999
COLUMN largest_bytes   HEADING 'Biggest|Bytes'  FORMAT 9,999,999,999
COLUMN largest_blks    HEADING 'Biggest|Blks'   FORMAT 999,999
COLUMN ratio           HEADING 'Percent'        FORMAT 999.999
COLUMN average_fsfi    HEADING 'Average|FSFI'   FORMAT 999.999
DEFINE 1 = report_output/&&db/free_spc
       COUNT(*) files,
       SUM(pieces) pieces,
       SUM(free_bytes) free_bytes,
       SUM(free_blocks) free_blocks,
       SUM(largest_bytes) largest_bytes,
       SUM(largest_blks) largest_blks,
       SUM(largest_bytes)/sum(free_bytes)*100 ratio,
       SUM(fsfi)/COUNT(*) average_fsfi
PAUSE Press Enter to continue

The report in Source 11.14 uses the view FREE_SPACE, which is based on the DBA_ view DBA_FREE_SPACE. This view is shown in Source 11.15. The freespace report is shown in Listing 11.13.

SOURCE 11.15 Freespace view listing.

rem Name:     free_space_view.sql
rem FUNCTION: Create free_space view for use by freespc reports
CREATE VIEW free_space
    (tablespace, file_id, pieces, free_bytes, free_blocks,
     largest_bytes,largest_blks, fsfi) AS
SELECT tablespace_name, file_id, COUNT(*),
    SUM(bytes), SUM(blocks),
    MAX(bytes), MAX(blocks),
FROM sys.dba_free_space
GROUP BY tablespace_name, file_id, relative_fno;

LISTING 11.13     Example of report from freespace report script.

Date: 10/14/01                                                                      Page:   1
Time: 12:41 PM                     FREE SPACE REPORT                           DBAUTIL
                                   galinux1 database 

                                      Free     Free      Biggest  Biggest  Average
Name            #Files   Frag         Byte      Blk        Bytes     Blks  Percent    
--------------- ------ ------ ------------ -------- ------------ -------- -------- ---CWMLITE              1      1   20,905,984    2,552   20,905,984    2,552  100.000  100.000
DBAUTIL_DATA         1      1    5,939,200      725    5,939,200      725  100.000 
DBAUTIL_INDEX        1      1    9,625,600    1,175    9,625,600    1,175  100.000 
DRSYS                1      1   12,845,056    1,568   12,845,056    1,568  100.000 
EXAMPLE              1      1      262,144       32      262,144       32  100.000 
INDX                 1      1   26,148,864    3,192   26,148,864    3,192  100.000 
SYSTEM               1      1      540,672       66      540,672       66  100.000 
TOOLS                1      3    8,192,000    1,000    7,274,496      888   88.800  
UNDOTBS              1      4  208,338,944   25,432  114,098,176   13,928   54.766  
UNDO_TBS2            1      1   19,595,264    2,392   19,595,264    2,392  100.000 
UNDO_TBS3            1      1   19,595,264    2,392   19,595,264    2,392  100.000 
USERS                1      1   25,952,256    3,168   25,952,256    3,168  100.000 

In an ideal situation, the tablespace data file(s) will show one extent (there will be one line in the report for each tablespace data file), and the biggest area will match the free area. In most cases, if the tablespace has been used for any length of time, there will be several extents, and the free area (which corresponds to total freespace in the tablespace) and the biggest area (which corresponds to the biggest area of contiguous free space) will not be equal.

If, after a coalesce, the number of extents isn't large, say, fewer than 20, and the mismatch between the two sizes is small, say, less than 10 percent difference between biggest and free, then there is probably nothing to worry about. If, on the other hand, either of these values is exceeded, the DBA should consider using the defragmentation methods described earlier. This report will not cover temporary tablespaces that are created as CREATE TEMPORARY TABLESPACE using tempfiles. 

Under Oracle8, Oracle8i, and Oracle9i, the tablespaces will be automatically defragmented by the SMON process if the value for the default storage parameter PCTINCREASE is set to greater than 0. The Free Space Fragmentation Index (FSFI) tells how much the freespace in a tablespace is fragmented--and comes to us by way of the Oracle DBA Handbook, by Kevin Loney (Oracle Press, 1994). A high value is good (with 100 the best); a low value is bad.

If you find yourself adding several data files to a single tablespace in a relatively short period of time, it may be wise to extrapolate the growth and then export, drop, and re-create the tablespace to the size required to prevent excessive addition of data files. Though Oracle suggests using autoextend data  files for tablespaces with expected growth, I still prefer manual control of tablespace growth so I am not surprised due to a runaway insert or other database mishap that causes the tablespace to grow unpredictably. However, turning on autoextend for a stable production environment may be the way to go if you understand the way the tablespaces are likely to grow. 

Spreading data files for large databases across several drives may be desirable for equalizing disk I/O. This is, however, a database-specific question, which has to be answered on a case-by-case basis.

If you have several large tables that would benefit from being spread across several disks, you might consider placing them in their own tablespaces, then sizing the data files for the tablespaces such that the data contained in the tables is spread. For instance, if you have a single table that contains a gigabyte of data, it may be advisable to spread this file across several platters.

To do this in Oracle7, create a table-specific tablespace on each of the platters that will hold the file, with each tablespace a fraction of the total size of the table; that is, if you want to spread the file across four drives, each data file would be 250 megabytes in size. Then, when you import the table, it will be spread across the four drives. The database will treat the table as one contiguous entity, but you will gain I/O speed by having spread the table across the available drives. Under Oracle8, Oracle8i, and Oracle9i, this can be accomplished with table partitioning, which allows a single table to be spread, by value range, across several files. Of course with RAID 1, RAID01/10, or RAID5, the spreading is done quasi-automatically so you would partition only for use of partition elimination or the benefits of parallel query and independent partition maintenance.

You should create each tablespace with a default storage parameter that takes into account the performance-critical tables in the application that resides in it. You should also do the best job you can estimating the size requirements for the tables as they are created and only default to the default storage for minor tables. Ideally, this size estimation should be pushed down to the developers of the applications.

To avoid fragmentation issues altogether, you can use the fixed-size extent model for your tablespaces. The fixed-size extent model states that, for any tablespace, all objects in that tablespace will have initial extent sizes that are multiples of a fixed default value, and next extent sizes that are equal to the default extent value for the tablespace. In the fixed-extent-size model, you have several tablespaces-- usually a small extent, medium extent, and large extent--each sized according to the needs of your application. By using the fixed-size-extent model, any extents that are released due to table or index maintenance will be reusable by any other object in the table. By allowing freed-extent reuse, fragmentation is no longer a concern in fixed-extent-size model tablespaces.

This is an excerpt from Mike Ault, bestselling author of "Oracle 10g Grid and Real Application Clusters".


Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.