At first glance, SQL operations like UPDATE and DELETE seem simple:
UPDATE users SET age = 30 WHERE id = 1;
But inside GBase database, this triggers a much deeper process:
π A transaction begins
π Data is modified
π Logs record every change
π The system ensures consistency and recovery
This article connects data operations + transaction mechanisms into one complete picture.
βοΈ Part 1: Data Operations in GBase
GBase supports standard SQL DML operations.
π UPDATE Example
UPDATE t_user
SET f_age = 20
WHERE f_userid = 1;
- Updates specific rows
- Returns number of affected rows
- Requires a
WHEREclause for safety
Example output:
1 row(s) updated.
ποΈ DELETE Example
DELETE FROM t_user
WHERE f_userid = 1;
- Removes selected rows
- Keeps table structure intact
Example output:
1 row(s) deleted.
These behaviors follow standard SQL semantics in GBase. ([GBase][1])
π§ Important: Every Operation is a Transaction
In GBase, every DML operation runs inside a transaction.
There are two modes:
1. Implicit Transactions (Default)
UPDATE users SET age = 30;
- Automatically starts
- Automatically commits
2. Explicit Transactions
BEGIN;
UPDATE users SET age = 30 WHERE id = 1;
COMMIT;
Or rollback:
ROLLBACK;
This gives developers full control over execution. ([cnblogs.com][2])
π§± Part 2: What Happens Internally?
Letβs break down an UPDATE:
UPDATE users SET age = 30 WHERE id = 1;
Internal Workflow:
- Transaction begins
- Original data is read
- Change is applied
- Log entry is written
- Transaction commits
π Nothing is changed βsilentlyββeverything is tracked.
π Part 3: Logging β The Backbone of Reliability
GBase uses logical logs to record transactions.
You can inspect logs with:
onstat -l
Example Output:
numrecs Log Space used
82067 12130972
This shows:
- Number of operations recorded
- Total log space usage ([GBase][3])
π Log Switching
When logs are full, GBase performs log switching:
onmode -l
After switching:
- Old log β archived or reused
- New log β becomes active
Example:
π Log ID changes (e.g., 18 β 19) ([GBase][3])
β οΈ Why Logging is Critical
1. Crash Recovery
If the system crashes:
- Logs are replayed
- Committed transactions are restored
2. Rollback Support
ROLLBACK;
- Undoes uncommitted changes
- Uses log history
3. Data Consistency
Logs ensure:
- No partial updates
- No corrupted data
π¬ Real Example: UPDATE + Logging
UPDATE t_employee
SET f_employeename = 'employee_updated'
WHERE f_employeeid = 11;
After execution:
- Row is updated
- Log entry is created
- Timestamp recorded
This proves that every change is tracked. ([GBase][3])
β‘ Performance Impact of Data Operations
Large operations can heavily affect logs.
Example:
UPDATE orders SET status = 'done';
Impact:
- Thousands of log entries
- Increased disk I/O
- Possible slowdown
Optimization Tips:
β
Use batch updates
β
Avoid full-table operations
β
Monitor logs regularly
π οΈ Monitoring Transactions
GBase provides tools for real-time inspection.
Check Logs
onstat -l
Check Transactions
onstat -x
Shows:
- Active transactions
- Commit/rollback status ([GBase][4])
Check Performance
onstat -p
Displays:
- Reads/writes
- Buffer usage
- System activity ([GBase][4])
π§ Key Insight
In GBase:
| Layer | Role |
|---|---|
| SQL | Defines data changes |
| Transaction | Controls execution |
| Logging | Records everything |
π These three layers work together to guarantee reliability.
π Final Thoughts
GBase turns simple SQL into a fully managed, recoverable process.
Instead of thinking:
β βI updated a rowβ
You should think:
β βI executed a transaction that was logged, validated, and committed safelyβ
Top comments (0)