I carefully monitor Oracle Tablespace utilization because I don’t buy into the space is cheap mantra. It’s especially important when we are dealing with SAN/FC/FLASH based storage. If you can effectively find the root cause of the vanishing space in an Oracle Tablespace you can save a good chunk of money for your organization and make your own life much easier by having fewer requests for new LUNs from the storage team.
Back in 2014 I was working for a company that operated a very large internet site and our space consumption was at the rate of 800GB every month, we were adding 4x400GB LUNs to our RAC cluster every two months. Then, one month we almost doubled our space consumption rate for no apparent reason. I decided that it was time to find the root cause of the issue and developed a series of scripts that helped us find the root cause in no time. I’ll show you how it works so you can adopt it in your workflow and DB monitoring.
The two scripts are:
- segs2: Fast Extending Segments in the last X minutes for given TS
- segs3: Fast Extending Segments Since Last Datafile Creation for given TS
These scripts use
Oracle AWR, specifically
dba_hist_seg_stat_obj so it’s important that you have a recent AWR snapshot to work with – you can easily create one using the following command:
Be careful – don’t add a call to
dbms_workload_repository.create_snapshot into the actual scripts and then run it over and over again – doing so can put a strain on a busy database.
Once you have a fresh AWR Snapshot created it’s very easy to use the scripts – simply login to the Oracle DB in question via
sqlplus and call the script:
For example to find which segments grew in the last 60 minutes in a tablespace
segs2.sql as follows:
wget https://s3.amazonaws.com/mve-shared/segs2.sql sqlplus / as sysdba @segs2.sql 60 DATA
or if you are interested in what segments grew in a tablespace
DATA since the last datafile was added run
segs3.sql as follows:
wget https://s3.amazonaws.com/mve-shared/segs3.sql sqlplus / as sysdba @segs3.sql DATA
I am considering incorporating the above two scripts into the new Oracle Monitoring Framework I am developing, so if you think this is valuable – sign up for the EvenTorEx Mailing List to start the discussion and get the private beta as soon as it’s ready (no SPAM here I guarantee it!):EvenTorEx Mailing List
Vitaliy Mogilevskiy December 16, 2015