Home > Oracle Database / Applications Tips > Oracle database administrator > Space usage: Predicting the future by means of geometric series
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Space usage: Predicting the future by means of geometric series


Predrag Radovic
03.19.2003
Rating: -2.33- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In our daily practice of managing space usage, we most often tend to focus on our largest objects when trying to forecast the amount of space we need to allocate for the future growth. Yet unpleasant surprises can often come from the side of smaller objects that are about to request additional extents (or a number of them). To answer the following questions...

  1. Is there enough space in my tablespaces to allocate the next N extents related to the tables that have less than M % of free space left?
  2. What percentage and amount of space will I be left with in case such allocations occur?
...all you need to do is run this query. It has been tested on Oracle 8.1.7, Standard Edition.

The total size of the next N extents is calculated as the sum of the geometric series, starting with the NEXT_EXTENT as the first element and having the multiplier of (PCT_INCREASE+1). The calculation takes into account both TABLE & INDEX extents for tables in question.

You will be asked to provide the following values:

  • the number of extents whose size you want to estimate
  • the percenatage of free space left within the tables of interest
Column "Currently_FREE_MB" will report the amount of free space currently available within a tablespace. Column "Next_Extents_MB" will tell you what will be the total size of your next extents. Columns "Free_PCT_Left" & "Free_MB_Left" will let you know how much space you will be left with, in percentages and Megabytes, respectively.

Any negative figures, or figures close to zero for the column FreePCTLeft should raise the alarm. The cases of PCT_INCREASE being equal to zero are also being taken into account. The assumption has been made tables are analyzed, thus the data dictionary columns referenced contain non-NULL values. You could easily build a function based on this query to focus on specific table names, number of extents and free space percentages only, passing these values as parameters.

SET termout on echo off feedback off termout on verify
off
VARIABLE vNextExtNo NUMBER 
VARIABLE vFreePCT NUMBER 

ACCEPT vNextExtNo PROMPT 'Enter the Number of Extents: '
ACCEPT vFreePCT  PROMPT  'Enter the Table Free Percent value: '

SELECT 
a.tablespace_name, b.currently_free_mb, a.next_extents_mb,
100-ROUND (a.next_extents_mb / b.currently_free_mb,2)* 100 free_pct_left,
ROUND (b.currently_free_mb - a.next_extents_mb, 2) free_mb_left
FROM (SELECT tablespace_name,
  ROUND (SUM (DECODE (pct_increase, 0, &&vnextextno * next_extent, 
(next_extent*(POWER(1+pct_increase/100,&&vnextextno)-1)/(pct_increase / 100))))/ 1048576,2) next_extents_mb
 FROM dba_segments
 WHERE (owner, segment_name) IN
  (SELECT owner, table_name
                 FROM dba_tables
   WHERE ROUND (100 * empty_blocks / (empty_blocks+blocks),2) < &&vfreepct + 1
   UNION
                 SELECT owner, index_name
                        FROM dba_indexes
                  WHERE (table_owner, table_name) IN
                         (SELECT owner, table_name
                                 FROM dba_tables
                                 WHERE ROUND (100*empty_blocks/empty_blocks+blocks),2) < &&vfreepct+ 1))
 GROUP BY tablespace_name) a,
 (SELECT tablespace_name,
  ROUND (SUM (bytes) / 1048576, 2) currently_free_mb
  FROM dba_free_space
        GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name;

UNDEFINE vNextExtNo
UNDEFINE vFreePCT

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Oracle database administrator
Understanding SQL string functions
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
How can I find statistics on total memory usage and database connections?
Installing multiple Oracle homes
Modifying SYS password in a RAC environment

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Oracle Development Solutions - SQL, J2EE, XML, SOA
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts