CockroachDB vs Google Cloud Spanner

It seems like both CockroachDB and Google Cloud Spanner are offering consistent, fault tolerant and scalable SQL databases.

As far as I can tell, from a user’s perspective, the major pros of CockroachDB are:

  1. Uses PostgreSQL’s wire protocol which has a lot of useful extensions
  2. Isn’t limited to just being deployed on GCP
  3. Open source

Are there any cons or other major differences?

Hi Olshansky,

You’ve identified most of the key differences. CockroachDB is open source (except for the enterprise features) and you can run it wherever you want, including on your laptop during development, any cloud provider, or your own physical servers. On the other hand, Spanner is a managed service which takes the administrative work off your hands; there is not (yet) an option to use CockroachDB-as-a-service.

As for your first point, our compatibility with other databases is an important factor, but “extensions” is not quite the way to look at it. PostgreSQL has many extensions which we do not support at this time, such as JSON columns, geospatial indexing, and full-text search (we intend to add these and other extensions in the future). Instead, it’s better to think of what we offer in terms of the SQL standard. Where databases differ we’re generally closer to PostgreSQL than others, but it’ll be easier to port an app that only uses standard features from MySQL than one that uses a lot of PostgreSQL-specific extensions.

It’s worth noting that Spanner’s SQL support is non-standard in a significant way: They don’t support the INSERT, UPDATE, or DELETE statements at all. Instead, all writes have to go through a different non-SQL API, and writes have to occur at the end of the transaction (you can’t, for example, do an UPDATE followed by a SELECT that sees the results of the first statement). CockroachDB supports the SQL write statements in the same way as other databases.


@bdarnell I really appreciate the detailed answer. This is exactly the type of side-by-side comparison I was looking for.

Thank you!

Regarding “Spanner’s SQL support is non-standard in a significant way: They don’t support the INSERT, UPDATE, or DELETE statements at all.”, According to … seems it supports. Or do I understand it wrong? Thanks!

Note that Ben’s post above is 3 years old. Spanner has since added support for the operations you mentioned in the intervening time. However Cockroach has also added several capabilities in the intervening time. Ben’s response mentions JSON columns and geospatial indexing - we have since added support for JSON columns and are currently working on adding support for geospatial indexing. If you have an interest in a more up to date comparison in a specific area, it may be worth creating a new thread.