How do you tell whether a database instance is experiencing a systemic performance problem or just one slow SQL statement?
In GBase Database (GBase 8s), the onstat -p command provides a useful starting point. It reports cumulative performance statistics since instance startup, helping DBAs identify potential issues involving buffer caching, locking, sequential scans, and resource waits.
Think of it as a database instance health sheet: one snapshot that helps you decide where to investigate next.
1. Collect Key Performance Statistics
Run the command as the gbasedbt user:
onstat -p
To focus on several commonly monitored fields, you can filter the output:
onstat -p | grep -E '%cached|deadlks|lokwaits|lockreqs|seqscans'
Five groups of indicators deserve attention:
-
%cached: Buffer cache hit ratio. A value above 95% is often used as an initial reference, but the appropriate target depends on workload characteristics. -
deadlks: Cumulative deadlocks detected and prevented. An increasing count warrants reviewing transaction behavior and application transaction ordering. -
lokwaits / lockreqs: Helps evaluate lock-wait activity relative to lock requests. A rising ratio may indicate concurrency contention. -
seqscans: Sequential scan activity. Persistently high values may justify reviewing query access paths and indexing strategies. -
bufwaits,ckpwaits,lgnwait: Help identify waiting activity associated with buffers, checkpoints, and logical log writes.
These indicators provide different perspectives on instance-level performance. No single field should be interpreted in isolation.
2. Understand the Limitation of Cumulative Statistics
There is an important limitation to onstat -p: its statistics accumulate over time.
This means a recent performance spike can be diluted by activity from previous days or weeks.
For example, an instance may have maintained a cache hit ratio of 97% for several weeks before gradually declining to 96% during recent peak workloads.
A single cumulative reading may make the decline look insignificant.
To investigate recent activity, you need a defined measurement window.
3. Use onstat -z to Reset Performance Counters
GBase Database provides onstat -z to reset cumulative performance statistics.
onstat -z
# Collect statistics during the observation period
onstat -p | grep -E '%cached|deadlks|lokwaits'
After resetting, subsequent readings provide a new basis for observing activity within the selected period.
Important: onstat -z resets statistics, not the database instance. It does not restart the instance or terminate existing sessions.
However, resetting removes the previous cumulative baseline. Archive the original output before executing it:
onstat -p > /tmp/onstat_p_before_$(date +%F).txt
onstat -z
This preserves a reference for later comparison.
4. Choose the Right Observation Window
Reset timing matters when building a reliable GBase Database monitoring baseline.
Consider two common mistakes:
- Resetting immediately after a peak period can leave the next observation window dominated by post-peak activity.
- Resetting during an early-morning lull and evaluating the entire day can dilute peak-hour pressure with low-load activity.
A more consistent approach is to select a fixed starting point, such as just before the first major business batch, and observe one complete business cycle.
Repeat this process across several cycles.
Over time, you can identify normal workload patterns for cache hit rates, deadlocks, and wait statistics.
This gives your team a more meaningful basis for defining monitoring thresholds.
5. Calibrate Thresholds to Your Workload
Reference values such as %cached > 95% and deadlks > 10 are starting points, not universal production alert rules.
For example:
- A cache hit rate below your historical baseline may justify investigating buffer-cache behavior and workload changes.
- An increasing deadlock count may indicate transaction-ordering issues that need application-level analysis.
- Rising lock waits may warrant reviewing concurrency patterns.
- Persistent sequential scans may justify examining query plans and indexing choices.
Remember that onstat -p identifies potential instance-level performance anomalies. It does not directly identify the SQL statement responsible.
Further investigation may require SQL diagnostics, execution-plan analysis, and transaction-level evidence.
Conclusion
A useful GBase Database health check is not simply about collecting performance statistics. It is about understanding what those statistics measure and when they were collected.
The combination of onstat -p and onstat -z provides a practical way to establish measurement windows, compare workload behavior, and develop monitoring thresholds based on actual operating conditions.
Instead of copying generic alert values, build a baseline from your own database workload.
Is your team's database cache hit-rate threshold calibrated to actual workload patterns, or is it still based on a generic 95% reference?
Top comments (0)