Beyond Rows: SQL is a Game Engine Now
Developers at Turso recently achieved a remarkable technical feat: they successfully compiled and ran the classic game DOOM entirely inside their database engine. This wasn't merely running the game on top of a database; its core logic executed directly within the database's computational core.
This stunt hinges on an often-overlooked aspect of database architecture. When users submit a SQL query, the database engine does not execute it directly. Instead, it compiles the query into a low-level instruction set, known as bytecode, which then runs on an internal Virtual Machine (VM). This VM, akin to a tiny CPU, has long processed operations for systems like SQLite.
Turso's team, rebuilding a database engine from scratch in Rust, leveraged this internal VM. They compiled DOOM's game logic into the database's own bytecode, allowing the same instruction set that handles `SELECT * FROM users` to render a first-person shooter. A small C to VDBE compiler (`vdbecc`) facilitated this transformation.
The demonstration proves a profound point: a database engine is far more than a passive storage system for rows and tables. It embodies a powerful, general-purpose computer, hidden in plain sight within the very infrastructure we use daily. This redefines our understanding of what a database can accomplish.
Unlocking the CPU Hidden in Your Database
SQL queries rarely execute directly. Instead, most databases, including SQLite, compile them into a compact bytecode. This bytecode then runs on an internal Virtual Database Engine (VDBE)—essentially a tiny, specialized CPU hidden within the database itself.
A team at Turso is fundamentally rebuilding this core engine in Rust. They envision it as the 'LLVM of databases,' a universal backend capable of supporting diverse database frontends. This includes current compatibility with SQLite and planned future integration for Postgres.
Running DOOM directly on this VDBE vividly demonstrates the computational power residing within. It proves this internal 'CPU' handles far more than simple data retrieval, executing complex game logic and rendering. The same instruction set processing `SELECT * FROM users` can now render a first-person shooter.
This feat underscores a profound shift: databases are evolving beyond mere data repositories. They are becoming general-purpose compute engines, capable of sophisticated operations previously confined to dedicated application layers. A real, programmable computer lives inside your database.
From Single-Writer to Global Scale
SQLite’s elegant simplicity long imposed a critical constraint: its single-writer model. This architecture, while robust for many use cases, limits throughput for concurrent write operations, creating a bottleneck in high-demand scenarios.
Turso’s Rust rewrite fundamentally rearchitects this core limitation. It implements Multi-Version Concurrency Control (MVCC), enabling high-throughput concurrent writes and transforming the database from a serialized resource into a highly scalable, parallel system.
Beyond concurrency, Turso integrates a suite of capabilities crucial for modern distributed applications. Developers gain powerful features such as: - database branching, offering isolated development environments - granular point-in-time restore for robust data recovery - native vector search, essential for AI-driven applications
It also includes robust WebAssembly (WASM) support. This allows direct execution of database logic at the edge or within browsers, blurring the traditional lines between client and server.
Enjoying this? Get one like it in your inbox each morning.
one email a day · unsubscribe in two clicks · no third-party tracking
This distributed design underpins Turso’s "Data Edge" advantage. It offers low-latency global replication, ensuring data resides geographically close to users, wherever they are. This capability directly competes with major cloud database providers, guaranteeing consistent, performant data access worldwide. Turso's ambitious architectural vision for a generalized database core is further elaborated in their work: We're building Postgres in Rust. Using the LLVM of databases - Turso.
The Next Frontier: Postgres on a SQLite Core
Turso’s strategic roadmap now targets deep compatibility with the Postgres dialect and wire protocol. This ambitious next step extends their Rust-powered core engine beyond its SQLite origins, aiming to serve a vastly broader database landscape. Imagine the flexibility: existing Postgres applications could connect seamlessly, running atop Turso’s high-performance engine, inheriting its modern architecture and multi-version concurrency control. This isn't just about translation; it's about a foundational shift.
This approach promises substantial benefits for Postgres users. It directly addresses classic Postgres challenges, such as the resource-intensive process-per-connection overhead that often limits scalability in traditional deployments. Users would gain an embeddable, modern Rust core, delivering superior edge performance, robust concurrent writes, and the operational simplicity of a single, highly optimized binary. It's like replacing a fleet of specialized engines with one universal, high-efficiency power plant.
Turso’s pursuit of Postgres compatibility concretizes their "LLVM of databases" vision. This concept envisions a single, highly-optimized virtual database engine capable of compiling and executing bytecode from diverse SQL 'languages,' encompassing both SQLite and Postgres. Such an architecture creates a more efficient, versatile data ecosystem, proving that a database engine can transcend its role as mere storage. It can function as a universal computational fabric, adaptable to multiple paradigms.
Frequently Asked Questions
What does it mean to run DOOM 'inside' a database?
It means the game's logic was compiled into the database's native instruction set (bytecode) and executed by its internal virtual machine, the same one that runs SQL queries. The game logic runs directly on the database engine's core, not in a separate application layer.
What is the 'LLVM of databases'?
This is Turso's vision for a universal, high-performance database core written in Rust. Like LLVM for compilers, it provides a common backend that different database frontends (like SQLite or Postgres) can compile down to, enabling shared optimizations and features.
Why did Turso run DOOM in their database?
It was a powerful proof-of-concept to demonstrate the generality and capability of their bytecode virtual machine (VDBE). It proves the engine is not just for `SELECT` statements but is a true general-purpose computational engine.
How does Turso differ from standard SQLite?
Turso is a Rust reimplementation of SQLite that adds modern features like Multi-Version Concurrency Control (MVCC) for concurrent writes, native vector search, database branching, and is designed for distributed edge environments with WebAssembly support.

