SawitDB v2.6.0
Release SawitDB v2.6.0
Modular Architecture (Codebase Refactor)
- Service-Oriented Core: Split monolithic
WowoEngine.jsinto specialized modules:- Logic Services:
ConditionEvaluator.js,JoinProcessor.js. - Managers:
TableManager.js,IndexManager.js. - Executors: Dedicated classes (Strategy Pattern) for
Select,Insert,Update,Delete,Aggregate.
- Logic Services:
- Server modularity: Split
SawitServer.jsintoAuthManager.js,ClientSession.js,RequestRouter.js, andDatabaseRegistry.js. - Maintainability: Reduced file size complexity by ~60%, enabling easier feature expansion.
True Multi-Threading (Worker Pool)
- Worker Pool Architecture: Migrated from
clustermodule toworker_threadsfor true parallelism. - IO/CPU Separation: Main thread handles Networking (IO), Worker threads handle Query Execution (CPU).
- High Concurrency: Architecture supports thousands of concurrent connections without blocking.
- Load Balancing: Implemented "Least-Busy" strategy to distribute queries to the least loaded worker.
- Fault Tolerance:
- Auto-Healing: Workers automatically restart upon crash.
- Anti-Stuck: Pending queries on crashed workers are immediately rejected/cleaned up.
- Per-Worker Stats: New
statscommand output shows query distribution and active load per worker.
AQL Syntax Parity (Agricultural Query Language)
Full feature parity with Generic SQL. You can now use AQL for advanced queries:
- JOINs:
GABUNG(Inner),GABUNG KIRI(Left),GABUNG KANAN(Right),GABUNG SILANG(Cross). - Ordering:
URUTKAN BERDASARKAN [field] NAIK|TURUN(Order By). - Pagination:
HANYA [n](Limit),MULAI DARI [n](Offset). - Grouping:
KELOMPOK [field](Group By),DENGAN SYARAT(Having). - Compatibility: Standard SQL syntax (
JOIN,ORDER BY,LIMIT) remains fully supported alongside AQL.
Advanced SQL Features
JOIN Enhancements
- LEFT OUTER JOIN: Returns all rows from left table, NULL for unmatched right rows
- RIGHT OUTER JOIN: Returns all rows from right table, NULL for unmatched left rows
- FULL OUTER JOIN: Returns all rows from both tables with NULL for non-matches
- CROSS JOIN: Cartesian product (no ON clause required)
-- LEFT JOIN example
SELECT * FROM employees LEFT JOIN departments ON employees.dept_id = departments.idDISTINCT & AGGREGATE
- DISTINCT:
SELECT DISTINCT category FROM products(orPANEN UNIK ...) to remove duplicates. - HAVING Clause:
GROUP BY region HAVING count > 5to filter aggregated results. - EXPLAIN Query Plan:
EXPLAIN SELECT ...to analyze execution strategy, index usage, and cost.
Security Improvements
- Password Hashing: Server authentication now uses SHA-256 with random salt
- Timing-Safe Comparison: Prevents timing attacks on password verification
- Input Validation: Table and column names validated against injection
- Regex Injection Fix: LIKE operator now escapes regex metacharacters
Performance & Code Quality
- Query Cache: Replaced expensive
JSON.parsewith shallow clone - True LRU Cache: Pager now properly tracks access order for eviction
- B-Tree Binary Search: Index operations now use O(log n) binary search
- Optimized Aggregates: MIN/MAX use single-pass loop (prevents stack overflow)
- Reduced JSON Parsing: DELETE/UPDATE operations optimize parsing overhead
- Bug Fixes:
- Fixed
_deleteFullScan()undefined table name - Cleaned up duplicate code (
_loadIndexes, pager checks) - AVG now returns
nullfor empty datasets - Fixed buffer pool leaks on read errors
- Fixed
Thanks to : @adityarizkyramadhan @fdciabdul @razmans @aljabary @rayocta303 @repo-unx