# TursoDB vs ChaiSQL

> ChaiSQL is an attractive option for Go developers who strictly require a pure Go, zero-CGO embedded SQL database implementing `database/sql` with a PostgreSQL-inspired dialect—provided its pre-production status fits your risk tolerance. TursoDB is the stronger choice for production workloads needing SQLite compatibility, MVCC concurrent writes, native vector search, and local-to-cloud sync.
> Canonical HTML: https://tursodb.cn/compare/turso-vs-chaisql/
> Language: en
> ChaiSQL Official Site: https://github.com/chaisql/chai

## Overview
Created by the author of Genji, ChaiSQL (`chaisql/chai`) is a pure Go embedded SQL database built on CockroachDB’s Pebble KV store with `:memory:` support and a standard Go `database/sql` driver. It eliminates CGO build complexity entirely, trading off native cross-language bindings, maturity, and cloud sync.

## Comparison Matrix
| Dimension | TursoDB | ChaiSQL |
| :--- | :--- | :--- |
| Core Engine | SQLite-compatible Rust B-tree — Pure Rust storage engine with non-blocking async I/O | Pure Go over Pebble KV — Zero-CGO SQL engine on LSM-tree storage and `:memory:` |
| Deployment Model | Polyglot native + Cloud — Rust, Go, JS/TS, Python, C, WASM, plus Turso Cloud sync | Static zero-CGO Go binaries — Embeds with `CGO_ENABLED=0`; no server daemon or cloud sync |
| Concurrency & Writes | Production MVCC writes — Optimistic BEGIN CONCURRENT engineered for concurrent OLTP workloads | Pre-production Pebble transactions — Local KV transactions under active pre-production development |
| Sync & Edge Replication | Native local-to-cloud sync — Bidirectional synchronization and in-process embedded read replicas | Local-only Go storage — No built-in replication or cloud sync layer |
| Multi-Tenant Isolation | Single-file per-tenant scale — Isolated database files locally and across Turso Cloud | DIY Pebble directories — Separate KV directories per tenant managed in Go code |
| Vector & AI Search | Built-in DiskANN vectors — Native vector columns and approximate nearest-neighbor search included | No built-in vector index — Focused on lightweight relational SQL over Pebble KV |
| SQL Dialect & Ecosystem | SQLite + polyglot drivers — Standard file format with Go `database/sql` and multi-language SDKs | Postgres-inspired Go SQL — Implements Go’s standard `database/sql` interface with Postgres syntax |
| License | MIT permissive license — Open-source core with no copyleft restrictions | MIT permissive license — Pure Go open-source core freely embeddable in commercial binaries |

## When to Choose TursoDB
- You need a production-oriented SQLite-compatible file format that works across Go, Rust, TypeScript, and Python.
- You want built-in local-to-cloud sync, embedded read replicas, or managed cloud hosting.
- Your workload requires MVCC concurrent writes or built-in DiskANN vector search.
- You want to inspect and debug local database files with the standard SQLite ecosystem.

## When to Choose ChaiSQL
- Your Go project enforces `CGO_ENABLED=0` for trivial cross-compilation (`GOOS`/`GOARCH`) and single static binary distribution.
- You prefer a PostgreSQL-inspired SQL dialect over SQLite’s dynamic typing inside a Go `database/sql` app.
- You want an LSM-tree disk layout via Pebble KV with a pure Go codebase you can step through with Delve.
- You are building internal tools, prototypes, or non-critical local state where ChaiSQL’s pre-production status is acceptable.

## Architecture Deep Dive
### Zero-CGO Go Simplicity vs. Native Rust Performance
Calling native Rust or C libraries from Go introduces CGO overhead and complicates cross-compilation pipelines across Linux, macOS, and Windows targets. ChaiSQL removes CGO completely by writing the entire SQL parser, planner, and Pebble KV storage path in pure Go—a major ergonomic win for Go CLI tools, at the cost of being limited to Go and still maturing toward production stability.

### Pebble KV Directory vs. Portable SQLite File + Sync
ChaiSQL stores tables inside a Pebble LSM-tree directory using a PostgreSQL-inspired dialect, which means files cannot be opened by standard SQLite utilities and remain local to one machine. TursoDB preserves single-file SQLite portability and layers bidirectional cloud sync on top when local Go services need remote durability or multi-node read replicas.

## FAQ
### Is ChaiSQL ready for critical production workloads?
ChaiSQL is currently under active pre-production development—its authors explicitly note it is not yet recommended for mission-critical production data. Evaluate stability and format-upgrade guarantees carefully before adopting it.

### Does TursoDB’s Go driver require CGO?
Embedded local execution via native Rust bindings typically uses FFI/CGO (or pure-Go HTTP/WebSocket clients when talking to Turso Cloud). If strict `CGO_ENABLED=0` local embedded execution is mandatory, pure-Go engines like ChaiSQL or transpiled SQLite drivers avoid CGO.

### How is ChaiSQL related to Genji?
ChaiSQL is the successor project by the creator of Genji, moving away from Genji’s document-oriented SQL experiment toward a cleaner, PostgreSQL-inspired relational SQL database on Pebble.
