Have you ever needed to analyze Oracle database growth trends but found yourself limited by current snapshot data? In real production environments, tracking database growth trends is a critical aspect of DBA life because this allows businesses not only to foresee the real position in terms of existing hardware but also enables planning future expenses for hardware and storage.
DBA_HIST_SEG_STAT is Oracle’s most powerful view for analyzing database growth trends and historical segment statistics. This comprehensive guide will show you exactly how to leverage this view for capacity planning and growth trend analysis.
Why Oracle Database Growth Trends Matter
Understanding database growth trends provides several critical benefits:
Capacity Planning: Predict when you’ll need additional storage based on historical patterns Budget Forecasting: Plan hardware purchases and cloud scaling costs effectively
Performance Optimization: Identify objects with rapid growth that may impact performance Compliance Management: Meet regulatory requirements for data retention and storage planning
Understanding DBA_HIST_SEG_STAT View
To generate data growth reports, Oracle provides various means which we’ll explore here. We can track growth for objects (tables, indexes), tablespaces, schemas, or even at database level using the views provided by Oracle.
There are few important views provided by Oracle which help us track growth:
Current State Views (Point-in-time data):
- DBA_SEGMENTS – Current segment sizes and allocation
- DBA_TABLESPACES – Current tablespace information
Historical Views (Growth tracking over time):
- DBA_HIST_SEG_STAT – Historical segment statistics (our focus)
- DBA_HIST_TABLESPACE_STAT – Historical tablespace statistics
- DBA_HIST_TBSPC_SPACE_USAGE – Historical space usage patterns
- DBA_HIST_SNAPSHOT – AWR snapshot metadata
Analysis Package:
- DBMS_SPACE – Space analysis and growth prediction methods
Views which do not have HIST in their name provide “accumulated till date” information. This means you can derive current size of an object using DBA_SEGMENTS and DBA_TABLESPACES. These views store data usage information in terms of BYTES.
To explain this, when we create a table (with segment allocation immediate option), Oracle allocates space for this object which is not utilized until we add a row. In simple terms, used space is the “High Water Mark” where Oracle has used the allocated space “up to”. This concept is brilliantly explained by Ask The Oracle Masters (AskTOM).
However, these views cannot give you comparative data growth charts where you can see past usage and forecast future storage requirements. To generate such reports, you should use historical views.
What Makes DBA_HIST_SEG_STAT Special
DBA_HIST_SEG_STAT captures comprehensive information about segments in historical form, including:
- Space allocation and utilization (our primary focus for growth analysis)
- Logical reads and physical reads (performance metrics)
- Buffer busy waits (contention indicators)
- Row lock waits (concurrency issues)
- Table scans (access pattern analysis)
- Physical writes (I/O activity)
When this historical view is combined with DBA_HIST_SNAPSHOT, we get the required information in comparative form for tracking data growth rates.
Tracking Database Growth with Historical Data
Important Limitation to Consider
The historical information captured will remain available in the database only for those dates and snapshots configured by the DBA to be kept in the database. Beyond this retention period, such information cannot be retrieved.
For example, if the DBA has configured 15 days of snapshots to be retained, we can retrieve comparative information for the last 15 days only.
If you want comparison reports for a year or more, you should follow alternate approaches:
- Create dedicated tables populated by scheduled jobs
- Query these custom tables instead of DB-supplied views
- Implement your own data retention policies
If such information wasn’t kept earlier, you cannot generate comparison reports beyond the snapshots available in the database.
Tablespace Growth Analysis Queries
Tablespace-Wise Growth on Daily Basis
Here’s a comprehensive query for daily growth reporting of tablespaces:
SELECT TO_DATE(TO_CHAR (snpshot.begin_interval_time,'DD-MM-YYYY'),'DD-MM-YYYY') daywise
, dhts.tsname tablespacename
, max(round((dhtsu.tablespace_size* dtblspc.block_size )/(1024*1024*1024),2) ) maximum_allocsize_GB
, max(round((dhtsu.tablespace_usedsize* dtblspc.block_size )/(1024*1024*1024),2)) maximum_usedsize_GB
FROM DBA_HIST_TBSPC_SPACE_USAGE dhtsu
, DBA_HIST_TABLESPACE_STAT dhts
, DBA_HIST_SNAPSHOT snpshot
, DBA_TABLESPACES dtblspc
WHERE dhtsu.tablespace_id= dhts.ts#
AND dhtsu.snap_id = snpshot.snap_id
AND dhts.tsname = dtblspc.tablespace_name
AND dhts.tsname NOT IN ('SYSAUX','SYSTEM')
GROUP BY TO_DATE(TO_CHAR (snpshot.begin_interval_time,'DD-MM-YYYY'),'DD-MM-YYYY')
, dhts.tsname
ORDER BY dhts.tsname
, daywise;
Sample Output Analysis:
| DAYWISE | TABLESPACENAME | MAXIMUM_ALLOCSIZE_GB | MAXIMUM_USEDSIZE_GB |
|---|---|---|---|
| 9-Jul-17 | TEST_DATA | 158 | 150.01 |
| 10-Jul-17 | TEST_DATA | 158 | 149.19 |
| 11-Jul-17 | TEST_DATA | 158 | 152.44 |
| 12-Jul-17 | TEST_DATA | 159 | 153.39 |
| 13-Jul-17 | TEST_DATA | 181 | 171.9 |
| 14-Jul-17 | TEST_DATA | 192 | 182.19 |
This output shows significant growth jumps on July 13th and 14th, indicating either data loads or structural changes that required capacity planning attention.
Object-Level Growth Monitoring
Daily Object Growth with Tablespace Context
For monitoring specific objects within tablespaces over the last X days:
SELECT * FROM
(SELECT ds.tablespace_name
, ds.segment_name
, TO_DATE(TO_CHAR (snpshot.end_interval_time,'DD-MM-YYYY'),'DD-MM-YYYY') daywise
, SUM(dhss.space_used_delta) / 1024 / 1024 "Space used (MB)"
, AVG(ds.bytes) / 1024 / 1024 "Total Object Size (MB)"
, ROUND(SUM(dhss.space_used_delta) / SUM(ds.bytes) * 100, 2) "Percent of Total Disk Usage"
FROM dba_hist_snapshot snpshot
, dba_hist_seg_stat dhss
, dba_objects dobj
, dba_segments ds
WHERE begin_interval_time > TRUNC(SYSDATE) – &pastdays
AND snpshot.snap_id = dhss.snap_id
AND dobj.object_id = dhss.obj#
AND dobj.owner = ds.owner
AND dobj.object_name = ds.segment_name
AND ds.segment_name = 'TEST_TAB1'
GROUP BY ds.tablespace_name,ds.segment_name,TO_DATE(TO_CHAR (snpshot.end_interval_time,'DD-MM-YYYY'),'DD-MM-YYYY')
ORDER BY ds.tablespace_name,ds.segment_name,TO_DATE(TO_CHAR (snpshot.end_interval_time,'DD-MM-YYYY'),'DD-MM-YYYY'));
Sample Output Interpretation:
| TABLESPACE_NAME | SEGMENT_NAME | DAYWISE | Space used (GB) | Total Object Size (GB) | Percent of Total Disk Usage |
|---|---|---|---|---|---|
| TEST_DATA | TEST_TAB1 | 8/28/2017 0:00 | 4.82 | 4.83 | 19.97 |
| TEST_DATA | TEST_TAB1 | 8/29/2017 0:00 | 4.72 | 4.83 | 13.97 |
Accumulated Object Growth Analysis
For understanding cumulative growth over the last X days:
SELECT ds.tablespace_name
, ds.segment_name "object name"
, dobj.object_type
, ROUND(SUM(dhss.space_used_delta) / 1024 / 1024 / 1024,2) "Growth (GB)"
FROM dba_hist_snapshot snpshot
, dba_hist_seg_stat dhss
, dba_objects dobj
, dba_segments ds
WHERE begin_interval_time > TRUNC(SYSDATE) – &past_days
AND snpshot.snap_id = dhss.snap_id
AND dobj.object_id = dhss.obj#
AND dobj.owner = ds.owner
AND dobj.object_name = ds.segment_name
AND ds.owner ='TESTOWNER'
GROUP BY ds.tablespace_name,ds.segment_name,dobj.object_type
ORDER BY 3 ASC;
Using DBMS_SPACE for Growth Predictions
The DBMS_SPACE package enables us to analyze segment growth and space requirements in Oracle with numerous methods. You can refer to Oracle Standard Documentation for exploring this package in detail.
OBJECT_GROWTH_TREND Method
The OBJECT_GROWTH_TREND function helps extrapolate the growth of particular tables and indexes:
select * from table(
DBMS_SPACE.OBJECT_GROWTH_TREND (
object_owner => 'TESTOWNER',
object_name => 'TEST_TAB1',
object_type => 'TABLE PARTITION',
partition_name => 'T1' ) );
Sample Growth Projection Output:
| TIMEPOINT | SPACE_USAGE | SPACE_ALLOC | QUALITY |
|---|---|---|---|
| 08-08-17 12:56:30 PM | 5163858429 | 5206179840 | INTERPOLATED |
| 09-08-17 12:56:30 PM | 5163858429 | 5206179840 | INTERPOLATED |
| 08-09-17 12:56:30 PM | 5163858429 | 5206179840 | PROJECTED |
Quality Indicators:
- INTERPOLATED: Based on historical data patterns
- PROJECTED: Future predictions based on growth trends
Best Practices for DBA_HIST_SEG_STAT Analysis
Monitoring Strategy
- Regular Reviews: Schedule weekly growth analysis reports
- Threshold Alerts: Set up monitoring for unusual growth patterns
- Capacity Planning: Use growth trends for hardware procurement
- Performance Correlation: Combine growth data with performance metrics
Query Optimization Tips
- Use Date Filters: Always limit queries with appropriate time ranges
- Index Considerations: Ensure AWR retention supports your analysis needs
- Result Caching: Cache frequently-used growth reports
- Parallel Processing: For large historical datasets, consider parallel execution
Data Retention Management
- AWR Settings: Configure appropriate snapshot retention periods
- Custom Tables: Create supplementary tracking for long-term analysis
- Archival Strategy: Implement procedures for historical data preservation
Conclusion
DBA_HIST_SEG_STAT provides the foundation for comprehensive Oracle database growth analysis and capacity planning. By combining this view with DBA_HIST_SNAPSHOT and complementary Oracle views, you can create powerful monitoring and prediction systems for your database environment.
The key insight from using these historical views is that effective capacity planning requires both short-term monitoring (current snapshots) and long-term trend analysis (historical data). This dual approach enables proactive database management and prevents storage-related performance issues.
Let us know in the comments if you have questions about specific DBA_HIST_SEG_STAT scenarios or if you’ve developed additional monitoring techniques using these Oracle historical views.
For related Oracle database monitoring topics, check our guides on Oracle memory monitoring and Oracle ASM configuration.
