Skip to content

SawitDB v2.6.0

Choose a tag to compare

@rayocta303 rayocta303 released this 10 Jan 04:59
· 8 commits to main since this release

Release SawitDB v2.6.0

Modular Architecture (Codebase Refactor)

  • Service-Oriented Core: Split monolithic WowoEngine.js into specialized modules:
    • Logic Services: ConditionEvaluator.js, JoinProcessor.js.
    • Managers: TableManager.js, IndexManager.js.
    • Executors: Dedicated classes (Strategy Pattern) for Select, Insert, Update, Delete, Aggregate.
  • Server modularity: Split SawitServer.js into AuthManager.js, ClientSession.js, RequestRouter.js, and DatabaseRegistry.js.
  • Maintainability: Reduced file size complexity by ~60%, enabling easier feature expansion.

True Multi-Threading (Worker Pool)

  • Worker Pool Architecture: Migrated from cluster module to worker_threads for 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 stats command 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.id

DISTINCT & AGGREGATE

  • DISTINCT: SELECT DISTINCT category FROM products (or PANEN UNIK ...) to remove duplicates.
  • HAVING Clause: GROUP BY region HAVING count > 5 to 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.parse with 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 null for empty datasets
    • Fixed buffer pool leaks on read errors

Thanks to : @adityarizkyramadhan @fdciabdul @razmans @aljabary @rayocta303 @repo-unx