Stop calculating database storage usage manually. GBase Database (GBase 8s) provides SMI views that can turn raw page counts into readable dbspace utilization percentages directly through SQL.

Today's practical trick is about making storage checks more accurate and consistent.

1. Why Manual Page Conversion Is Error-Prone

The onstat -d command reports storage information using page counts.

onstat -d 

The size and free values represent pages, not bytes. To calculate actual storage capacity, you need to multiply them by pgsize.

This is simple arithmetic, but it is also one of the easiest places to introduce mistakes during routine database checks.

For example:

  • Forgetting the page size produces incorrect capacity calculations.
  • Treating page counts as bytes leads to misleading reports.
  • Different engineers may use different calculation methods.

GBase Database provides another approach: use SMI queries to calculate storage utilization directly.

2. Use SMI to Calculate Dbspace Usage

The following SQL joins syschktab (chunk details) with sysdbstab (dbspace attributes) to generate a dbspace-level storage report.

SELECT A.dbsnum as No, trim(B.name) as name, format_units(sum(chksize), 'p') as DBS_SIZE, TRUNC(100-sum(decode(mdsize,-1,nfree,udfree))*100/sum(chksize),2)||'%' as used FROM syschktab A, sysdbstab B WHERE A.dbsnum = B.dbsnum GROUP BY A.dbsnum, name ORDER BY A.dbsnum; 

The query provides:

  • Dbspace number
  • Dbspace name
  • Total storage size
  • Used storage percentage

Instead of manually converting pages into bytes and calculating utilization, the SQL produces a consistent report.

The format_units(...,'p') function converts page-based storage information into readable units using the database page size.

This is particularly useful when building daily GBase Database storage reports and automated monitoring checks.

3. Monitor Dbspace Status Alongside Usage

Storage utilization is only part of the picture.

Dbspace status is equally important. The dbsstatus field provides information about whether a dbspace is operational.

Three states are worth monitoring:

Status Meaning Priority
Disabled Dbspace unavailable Highest
Recovering Dbspace undergoing recovery Requires attention
Operational Normal operating state Normal

A dbspace with low utilization can still have an availability problem.

Combining storage percentages and dbspace status allows a monitoring report to answer two important questions:

  1. Which dbspaces are approaching their capacity limits?
  2. Is any dbspace unavailable or undergoing recovery?

This is more useful than reporting storage percentages alone.

4. Choose Between onstat and SMI

GBase Database provides both raw storage readings and SQL-based monitoring views. They serve different purposes.

Use onstat -d when you need:

  • Detailed chunk information
  • Physical storage paths
  • Raw page counts
  • Cross-validation of monitoring results

Use SMI queries when you need:

  • Dbspace usage percentages
  • Readable storage reports
  • Consistent capacity calculations
  • SQL-based monitoring integration

A practical approach is to use SMI for daily reporting and retain onstat -d for troubleshooting and verification.

5. Understand Dbspace Types and Monitoring Boundaries

The dbstype field in sysdbstab distinguishes different dbspace types.

Some descriptions contain mirror-related terminology. These are field descriptions for understanding storage metadata, not instructions to perform deployment or switching operations.

Keeping monitoring interpretation separate from storage configuration changes helps prevent unnecessary actions during troubleshooting.

There is also an important operational difference between SMI queries and onstat commands.

SMI queries must be executed through dbaccess with a connection to the sysmaster database.

For example:

dbaccess sysmaster - 

By contrast, onstat commands read instance information directly and do not require a database connection through dbaccess.

This distinction matters during incidents. If the instance is hung or database connections are unavailable, repeatedly retrying an SMI query is unlikely to help. Use the appropriate diagnostic entry point for the situation.

Final Takeaway

Reliable GBase Database storage monitoring should not depend on individual engineers performing manual calculations.

Use SMI to standardize dbspace utilization reports, check dbsstatus for availability, and keep onstat -d for detailed storage verification.

The goal is simple:

  • Reduce manual calculation errors.
  • Standardize storage reports.
  • Detect availability problems early.
  • Separate monitoring from configuration changes.
  • Make daily database checks repeatable.

GBase Database already provides the raw data and readable SMI views. The key is choosing the right tool and turning its output into consistent operational rules.

Do you calculate dbspace usage manually from page counts, or generate utilization reports directly through GBase Database SMI queries?