When your database slows down, the problem is rarely obvious.
It could be:
- Too many locks
- Buffer shortages
- High CPU usage
- Excessive sequential scans
To solve this, GBase database provides detailed runtime metrics through tools like onstat.
These metrics allow you to see whatβs really happening inside the database engine.
π§ Why Metrics Matter
SQL alone tells you what happened.
Metrics tell you why it happened.
For example:
- Slow query β Is it CPU, I/O, or locks?
- High latency β Is the buffer pool full?
- Deadlock β Which sessions are involved?
π GBase exposes these answers through internal counters.
π οΈ Key Tool: onstat -p
The onstat -p command provides performance statistics of the database.
onstat -p
It includes critical metrics such as:
- CPU usage
- Buffer activity
- Lock statistics
- I/O operations
These counters are continuously updated during runtime.
π Important Metrics Explained
π Lock Metrics
-
lockreqsβ Number of lock requests -
lokwaitsβ Times sessions had to wait for locks -
deadlksβ Number of detected deadlocks
π High lokwaits usually means contention between transactions. (GBase)
πΎ Buffer & Memory Metrics
-
ovbuffβ No available buffer occurrences -
bufwaitsβ Times sessions waited for buffer
If these increase:
π Your system may suffer from memory pressure or poor configuration (GBase)
β‘ CPU Metrics
-
usercpuβ CPU used by user threads -
syscpuβ System-level CPU usage
These values help identify:
- CPU bottlenecks
- Inefficient queries
π I/O and Scan Metrics
-
seqscansβ Number of sequential scans -
isrd/iswrβ Read/write operations
π High sequential scans often indicate missing indexes (GBase)
π Transaction Metrics
-
isctβ Commit count -
isrbβ Rollback count
These help evaluate:
- Transaction success rate
- Application stability
𧬠Going Deeper: Thread-Level Analysis
You can inspect thread-level behavior:
onstat -g tpf <thread_id>
This shows:
- Lock requests
- Reads/writes
- Log usage
- Buffer activity
Each threadβs workload can be analyzed in detail. (GBase)
π₯ Session-Level Monitoring
To inspect active sessions:
onstat -g ses
Youβll see:
- Current SQL
- Isolation level
- Lock mode
- Memory usage
This helps identify:
π Which session is causing problems
π What query is running right now (GBase)
π§ Real-World Troubleshooting Scenario
Problem: Slow Query
Step 1: Check CPU
onstat -p
If usercpu is high β CPU bottleneck
Step 2: Check Locks
onstat -p
If lokwaits increases β lock contention
Step 3: Check Buffer
onstat -p
If bufwaits increases β memory issue
Step 4: Drill into Session
onstat -g ses
Find the problematic SQL.
βοΈ How GBase Stores and Tracks Metrics
GBase maintains these metrics in shared memory structures, updated continuously during runtime.
This allows:
- Real-time monitoring
- Low-overhead diagnostics
- Accurate system insights
β‘ Performance Optimization Tips
β Reduce Lock Contention
- Shorten transaction duration
- Use proper isolation levels
β Optimize Queries
- Avoid full table scans
- Add indexes where needed
β Tune Memory
- Increase buffer pool size
- Monitor
ovbuffandbufwaits
β Monitor Regularly
Donβt wait for problemsβtrack metrics continuously.
π Metrics vs Logs
| Aspect | Metrics | Logs |
|---|---|---|
| Real-time | β Yes | β No |
| Detail level | High | Medium |
| Use case | Performance | Auditing |
π Final Thoughts
GBase is powerful not just because of SQLβbut because of its deep observability.
With tools like onstat, you can:
π Understand system behavior in real time
π Diagnose issues quickly
π Optimize performance precisely
π¬ Key Takeaway
Instead of guessing:
β βWhy is my database slow?β
You can now answer:
β
CPU issue
β
Lock contention
β
Memory bottleneck
π₯ What to Try Next
- Run
onstat -pduring peak load - Track lock contention trends
- Analyze sequential scan frequency
If you want, I can also generate:
- π A visual cheat sheet for onstat commands
- π§ͺ A hands-on lab with simulated performance issues
- π Or a GBase vs MySQL performance monitoring comparison π
Top comments (0)