# TursoDB vs PostgreSQL

> PostgreSQL is unmatched for complex relational workloads inside a centralized database—rich data types, PostGIS, stored procedures, row-level security, and massive multi-writer throughput. TursoDB trades that heavy server feature set for zero-daemon embedding, true database-per-tenant isolation at minimal cost, and built-in local-to-cloud sync.
> Canonical HTML: https://tursodb.cn/compare/turso-vs-postgresql/
> Language: en
> PostgreSQL Official Site: https://www.postgresql.org/

## Overview
Comparing TursoDB and PostgreSQL is primarily a choice between an in-process, file-per-tenant architecture and a centralized client-server cluster. Both support MVCC and vector search, but they optimize for very different deployment topologies and operational boundaries.

## Comparison Matrix
| Dimension | TursoDB | PostgreSQL |
| :--- | :--- | :--- |
| Core Engine | Embedded Rust engine — SQLite-compatible core built on non-blocking async I/O | C client-server RDBMS — Shared buffers, WAL, and process-per-connection server architecture |
| Deployment Model | Zero-daemon in-process library — Embeds directly with optional Turso Cloud sync and replicas | Dedicated TCP server — Self-hosted or managed (RDS, Neon, Supabase) requiring connection pools |
| Concurrency & Writes | Optimistic MVCC writes — BEGIN CONCURRENT designed for moderate per-tenant write workloads | Enterprise multi-writer MVCC — Fine-grained row locks, advisory locks, and high sustained write throughput |
| Sync & Edge Replication | Native client-to-cloud sync — Built-in bidirectional sync and in-process embedded read replicas | Server-to-server replication — Streaming and logical replication; client sync needs ElectricSQL or PowerSync |
| Multi-Tenant Isolation | Physical database-per-tenant — Millions of lightweight isolated DBs with near-zero idle RAM | Shared-schema with RLS — Thousands of separate Postgres DBs incur heavy catalog and pool overhead |
| Vector & AI Search | Built-in DiskANN vectors — Native vector columns and ANN index with zero extensions | Mature pgvector extensions — pgvector and pgvectorscale provide HNSW and IVFFlat vector indexes |
| SQL Dialect & Ecosystem | Lean SQLite dialect — Simpler type system without stored procedures or server extensions | Rich ANSI SQL + extensions — JSONB, arrays, PostGIS, full-text search, triggers, and PL/pgSQL |
| License | MIT permissive license — Open-source core with no copyleft restrictions for commercial apps | PostgreSQL License — Permissive BSD/MIT-like open-source license governed by community |

## Verified Real-Hardware Benchmarks
> Environment: Intel(R) Xeon(R) E-2288G CPU @ 3.70GHz (8c) · kvm · Linux 6.8.0-147-generic · io_uring=ENABLED · Turso 0.8.4 · Recorded 2026-12-05T19:14:15Z

### Per-Agent DB Provisioning Time (1000 DBs · bun 1.4.5) (lower is better)
| Engine / Series | Value | Notes |
| :--- | :--- | :--- |
| Avg create + schema + seed per DB | 3.3 ms | - |

### Resource Footprint Across 1000 Isolated DBs (bun 1.4.5) (lower is better)
| Engine / Series | Value | Notes |
| :--- | :--- | :--- |
| Process RSS (1000 warm handles open) | 2165.21 MB | base 39.62MB / create 58.71MB / closed 169.09MB |
| Total disk footprint (.db + WAL) | 24 MB | - |

### Multi-Tenant Read p99 @ 50 concurrency (bun 1.4.5) (lower is better)
| Engine / Series | Value | Notes |
| :--- | :--- | :--- |
| TursoDB 1000 Isolated DBs — Warm Cache (bun 1.4.5) | 0.56 ms | p50 0.395ms · in-process (0 TCP) |
| PostgreSQL 16 Shared Table — Warm Pool (1000 tenants) | 7.552 ms | p50 2.255ms · max=50 TCP named-prepared |
| TursoDB 1000 Isolated DBs — Fresh Open+Close | 30.315 ms | zero-cache serverless handle open |

### Key Takeaways
- At 50 concurrent reads across 1,000 tenants, in-process TursoDB (1,000 warm isolated DB handles, 0 TCP) achieved 0.56 ms p99 on Bun (1.23 ms on Node.js) vs PostgreSQL 16.15 warm pool (max=50 connections, named prepared statements) at 7.55 ms p99 on Bun (8.02 ms on Node.js)—6.5× to 13.5× lower tail latency.
- Provisioning 1,000 physically isolated TursoDB databases (create + schema + seed) completed in 2.72–3.30 ms per DB with only 24.0 MB total disk footprint (.db + WAL).
- Honest trade-off disclosed: holding all 1,000 warm handles open concurrently uses ~2.16 GB RSS (~2.1 MB/handle, dropping to 169 MB once closed), while zero-cache fresh open+close runs at 28.4–30.3 ms p99—making an LRU handle cache (e.g., top 100–250 active tenants) the optimal production pattern.

## When to Choose TursoDB
- You want physical database-per-tenant isolation for SaaS accounts, workspaces, or ephemeral AI agent sandboxes.
- You need zero-latency local reads via embedded replicas or offline-capable client/edge execution.
- You want zero connection-pool management (no PgBouncer) and near-zero idle cost for thousands of quiet databases.
- Your schema fits cleanly in relational tables + vector search without requiring heavy server-side PL/pgSQL logic.

## When to Choose PostgreSQL
- Your core workload involves complex multi-table joins, cross-tenant analytics, or high concurrent writes against a single massive dataset.
- You rely on PostgreSQL-specific capabilities like PostGIS, JSONB GIN indexing, custom data types, partitioned tables, or Row-Level Security.
- You need mature enterprise tooling for logical replication, CDC pipelines (Debezium), and fine-grained database roles.
- Your team already operates PostgreSQL clusters with established DBA practices and compliance certifications.

## Architecture Deep Dive
### Shared Cluster vs. Database-per-Tenant Isolation
In PostgreSQL, multi-tenancy usually means one shared database protected by tenant_id filters and Row-Level Security, because spinning up tens of thousands of separate Postgres databases bloats connection pools and shared memory. TursoDB flips that economics: each tenant, user, or AI agent gets an isolated SQLite-compatible file that costs virtually nothing when idle and makes tenant backup, export, or deletion a single-unit operation.

### Network Hop Latency vs. Server Feature Depth
Every PostgreSQL query traverses a network socket (often through a pooler) to a centralized primary or regional read replica, which works well for backend microservices co-located with the database. TursoDB eliminates network round-trips on reads by embedding a synced copy next to your code, though you give up PostgreSQL’s rich procedural languages, custom operators, and extension ecosystem.

## FAQ
### Can TursoDB replace PostgreSQL for a large monolithic B2B SaaS?
It depends on data coupling. If your SaaS cleanly partitions data by workspace or customer, TursoDB’s database-per-tenant model is a strong fit; if you constantly run cross-tenant joins and heavy relational reporting in one database, PostgreSQL is usually better.

### Does TursoDB support PostgreSQL features like JSONB, PostGIS, or RLS?
No. TursoDB follows the SQLite dialect (with JSON functions and native vectors), so workloads dependent on PostGIS, GIN indexes, or server-side Row-Level Security should stay on PostgreSQL.

### Can teams use PostgreSQL and TursoDB together?
Yes. A common pattern is keeping core billing and cross-tenant analytics in PostgreSQL while using TursoDB for per-agent memory, edge caches, or offline-first client databases.
