HeadlinesBriefing favicon HeadlinesBriefing.com

Stoolap/Node: A Fast New Node.js Driver vs. SQLite

Hacker News •
×

A new Node.js driver called Stoolap, built for an embedded SQL database written in Rust, is making waves with its impressive performance. Designed to provide direct access to the Stoolap database engine from JavaScript and TypeScript, it bypasses the need for an HTTP server or serialization overhead. The driver leverages NAPI-RS for native bindings, promising a streamlined experience for developers.

Benchmarking against `better-sqlite3`, a popular SQLite driver, revealed some surprising results. Stoolap outperformed SQLite in 47 out of 53 tests. The driver excels in complex queries, with 138x faster performance in `COUNT DISTINCT` operations. This advantage stems from Stoolap's MVCC transactions, cost-based query optimizer, and parallel execution capabilities, making it a strong contender for analytical workloads.

Stoolap's speed gains are most noticeable on complex queries, in contrast to SQLite's slight advantage on simple, single-row operations. The driver offers both async and sync APIs, file-based persistence, and supports transactions and prepared statements. Users can get started with `npm install @stoolap/node`. The project offers pre-built binaries for multiple operating systems, eliminating the need for a Rust toolchain.

The Node.js driver, currently at v0.3.1, provides the full API for the Stoolap database. Future releases are planned, including connection pooling helpers and streaming query support. Should you encounter any issues or have feature requests, the project encourages users to engage on GitHub. The Stoolap driver offers significant performance gains, especially for analytical and complex SQL queries.