NEW

SurrealDB 4 is here, introducing SurrealDB Earth and SurrealDS!

Learn more

This is what we always hoped SurrealDB would become

Company
Featured
Engineering

Nov 9, 20267 min read

Tobie Morgan Hitchcock

Tobie Morgan Hitchcock

Show all postsThis is what we always hoped SurrealDB would become

Our newsletter

Get tutorials, AI agent recipes, webinars, and early product updates in your inbox every two weeks

This is what we always hoped SurrealDB would become. It's what we set out to build, and today, it's here.

SurrealDB 4 is now generally available. It is the database and memory for every agent. And with it comes SurrealDB Earth: serverless SurrealDB, built on Cloudflare, that scales to as many agents and users as you need, wherever they are. Alongside SurrealQL and the ISO GQL graph queries SurrealDB already answers, the engine now speaks PostgreSQL and MySQL over their own wire protocols.

I've written a lot of release posts, and this is the first time the thing we're shipping matches the picture I had in my head when we started.

When we started SurrealDB, the idea was simple to say but hard to build. An application's data comes in many shapes: records, documents, the relationships between them, and the text and meaning inside them. I wanted one database that could hold all of it, under one set of rules, and answer a question that crosses all of those shapes in one query. I wanted it to carry apps built for a billion people, and to stay light enough to give each small app or user a database of its own. We didn't know it at the time, but that second part is exactly the shape AI agents turned out to need.

We released SurrealDB publicly in 2022. Version 1.0 followed in September 2023. People liked the idea straight away, and more than four million developers have built with it since. Looking back at those early years, the idea was ahead of the engine. Some people tried SurrealDB, loved what it could express, and left because it wasn't fast enough or stable enough for what they needed.

Most of this year went into the part nobody sees until they run a database in production.

SurrealDB 4 brings more than 240 fixes to the database that no 3.x release contains, almost all of them merged in October. It also fixes more than 90 bugs reported on GitHub by people in our community, who took the time to write down what broke. Thank you.

We also rebuilt the query core. That's the kind of change that can quietly break years of behaviour, so the team built a safety net first: until the old engine was removed in early October, every query test ran on both the old engine and the new one, and had to return the expected result on both. Of everything in this release, that's the work I'm proudest of. It's how we know the new engine gave the same answers as the old one across our test suite, only faster.

Today more than 4,500 SurrealQL test files run on every change. Each one is a plain SurrealQL query with the results it must return written above it, like this made-up example:

CREATE person:tobie CONTENT { name: 'Tobie' };
SELECT VALUE name FROM person;

A database scales furthest when each query costs less. SurrealDB 4 rebuilds the query core to do less work for every query, and SurrealKV 1.0, which replaces RocksDB as the storage engine, does less work for every read and write underneath it. Our benchmarks page gives the full results and how they were measured. We'll continue to expand our benchmarks for: distributed database comparisons, vector search (HNSW throughput and recall), full-text search (BM25), and graph query performance benchmarks.

While we were doing that work, the world changed around us. More and more software is now written and run by agents, and every agent needs somewhere to keep what it knows.

That changes what a database is for. It used to be one large thing that a whole company shared. Now it can be thousands of small things, as many as your agents and users need. Each needs to start the moment it's needed and stay out of the way when nobody is using it.

That's SurrealDB Earth. It's serverless SurrealDB, built on Cloudflare. Every Earth database is its own isolated instance, with dedicated storage and commit log, keeping each tenant's data separate. A database starts with its first query, in ~300ms from cold, and scales to zero about a minute after its last one. All you need to start for free is an email address.

Three things together make this release what we hoped for:

  1. 1.

    It scales to as many agents and users as you need, each database isolated from every other, and scaled to zero when nobody is using it.

  2. 2.

    It speaks the languages agents already know. PostgreSQL and MySQL clients connect over their own wire protocols and write the SQL they already know. For years, using SurrealDB meant learning SurrealQL first. I still think SurrealQL is the best way to ask a question that crosses documents and graphs, but now it's a choice rather than the price of entry. SurrealDB supports a defined subset of each SQL dialect, and the PostgreSQL and MySQL protocol references list what is supported.

  3. 3.

    It remembers in one query, and that is what SurrealDB Agent Memory is built on. An agent can ask what's closest in meaning to a question, what it's connected to, and what was actually said, and get one answer inside one transaction. That's what memory is, and it's what a multi-model database was always for. Agent Memory, launched in October, is the managed way to get it.

Becoming the biggest database in the world was never the first goal. Building the right one was, and now that it's here, there is room to grow with it. At peak, Earth handles 10+ billion rows per second, fully transactional.

The other half of growing is staying durable while you do it. SurrealDS, our new distributed storage, puts every write on two disks in two zones before it's acknowledged, with object storage holding the durable copy. It's built to stay durable through node and zone failures: a machine that fails is replaced, and its replacement recovers from the surviving copy and object storage. If you're going to trust a database with an agent's memory, that matters as much as speed does. SurrealDS is available in SurrealDB Cloud multi-node clusters and Enterprise Edition.

To try the SQL support on your machine, install SurrealDB 4:

curl -sSf https://install.surrealdb.com | sh

Then start it with the PostgreSQL listener on, and connect with psql. The listener is off by default, and the --postgres-bind flag in the first command is what turns it on (--mysql-bind does the same for MySQL):

surreal db start --user root --pass secret --postgres-bind 127.0.0.1:5432 memory
psql "host=127.0.0.1 port=5432 user=root password=secret dbname=main/main options='-c dialect=pgsql'" -c 'SELECT 1;'

SurrealDB 4 is recommended for new (greenfield) database deployments. For existing 3.x deployments, we recommend upgrading to 4.1 once available. Our internal migration tests have performed well, but we want to validate the process further with the community across a broader range of real-world workloads before recommending it for production.

For those who want to test it now, SurrealDB 4 includes an experimental in-place upgrade process that doesn't require exporting and importing your data. It requires explicit opt-in and is one-way, so take and verify a backup, test on a copy of your data, and update your SDKs first. RocksDB datastores are automatically converted to SurrealKV, and some indexes need rebuilding. See the 3.x to 4 upgrade guide for details.

There's plenty still to do. Recursive CTEs, rate limiting, window functions and the catalog tables that ORMs read are next for our SQL support. Database branching, forking and near-instant copies build on the same design as SurrealDS, and they are coming next.

If you tried SurrealDB a while ago and moved on, I'd love you to try it again.

Start free on SurrealDB Earth or install SurrealDB 4 to test it locally. See everything in the release.

This is what we set out to build. It's here. I can't wait to see what you build with it.

Tobie

Related posts

Our newsletter

Get tutorials, AI agent recipes, webinars, and early product updates in your inbox every two weeks