When you execute SQL in a database, things don’t just “happen” instantly behind the scenes.
Every operation—whether it’s:
- INSERT
- UPDATE
- DELETE
…is carefully tracked and recorded.
In GBase database, this is handled through transactions and logging mechanisms, which ensure:
✅ Data consistency
✅ Crash recovery
✅ Reliable execution
🧠 What is a Transaction?
A transaction is a unit of work that must follow the ACID principles:
- Atomicity → All or nothing
- Consistency → Valid state maintained
- Isolation → No interference between operations
- Durability → Changes are permanently stored
✏️ Example: Data Update in GBase
UPDATE t_employee
SET f_employeename = 'employee_updated'
WHERE f_employeeid = 11;
After execution:
- The row is updated
- The change is recorded in logs
- The transaction is committed
👉 GBase confirms updates with row count feedback ([GBase][1])
🧱 How GBase Logging Works
GBase uses two types of logs:
1. Physical Logs
- Record low-level storage changes
- Track page-level modifications
2. Logical Logs
- Record SQL-level operations
- Track transactions like INSERT/UPDATE/DELETE
Example command to view logs:
onstat -l
This shows:
- Log usage
- Log sequence numbers
- Space utilization
📊 Example: Log Output
From GBase:
Logical Logging:
numrecs Log Space used
82067 12130972
This indicates:
- Number of records written to logs
- Space consumed by transactions ([GBase][1])
🔄 Log Switching (Important Concept)
As transactions increase, logs fill up.
GBase automatically performs log switching:
- Old log → archived or reused
- New log → becomes active
After switching:
👉 Log ID changes (e.g., 18 → 19) ([GBase][1])
⚠️ Why Logging Matters
1. Crash Recovery
If the database crashes:
- Logs are replayed
- Data is restored to a consistent state
2. Transaction Rollback
If something fails:
ROLLBACK;
GBase uses logs to undo changes.
3. Data Consistency
Logs ensure:
- No partial updates
- No corrupted state
🛠️ Monitoring Transactions in Real Time
Use onstat tools to inspect activity:
View Log Status
onstat -l
View System Activity
onstat -p
View Sessions
onstat -g ses
These commands help track:
- Active transactions
- Resource usage
- System performance ([GBase][2])
🔬 Behind the Scenes: What Happens on UPDATE
When you run:
UPDATE users SET age = 30 WHERE id = 1;
Internally:
- Transaction begins
- Old data is recorded in logs
- New data is written
- Logs are updated
- Transaction commits
⚡ Performance Considerations
Logging is essential—but it has cost.
Potential Issues:
- Heavy log usage during large updates
- Disk I/O pressure
- Log space exhaustion
Optimization Tips:
- Batch updates instead of row-by-row
- Monitor log usage regularly
- Allocate sufficient log space
🏢 Real-World Scenario
Case: Bulk Data Update
UPDATE orders SET status = 'processed';
Impact:
- Thousands of log entries
- Increased disk writes
- Possible performance slowdown
👉 Solution:
- Run in batches
- Monitor logs with
onstat -l
🔐 Safety Best Practices
✅ Always Use Transactions
BEGIN;
UPDATE ...
COMMIT;
✅ Monitor Log Usage
onstat -l
✅ Plan Log Capacity
Ensure logs don’t fill up during peak workloads.
🚀 Final Thoughts
Transactions and logging are the foundation of database reliability in GBase.
They ensure:
- Every change is tracked
- Every failure can be recovered
- Every operation is consistent
Top comments (0)