Jump to Content
Databases

Introducing PostgreSQL interface for Spanner: availability at scale with the interface you know

June 23, 2022
https://storage.googleapis.com/gweb-cloudblog-publish/images/PostgreSQL_UxKXx1q.max-2600x2600.jpg
Justin Makeig

Senior Product Manager

Cloud Spanner is our fully managed relational database that provides the highest levels of consistency and availability at any scale. It‘s trusted by organizations in industries like financial services, retail, and gaming to run their most demanding workloads. We’re excited to announce today that we’re bringing this same scale and reliability to the fast-growing PostgreSQL community with the general availability of the PostgreSQL interface for Cloud Spanner. The PostgreSQL interface is available for no additional cost in all regional and multi-regional Spanner configurations.

The PostgreSQL interface is a new way to access Spanner. It combines the familiarity and portability of PostgreSQL with the unmatched scalability and fully managed experience of Spanner. Devops teams that have scaled their databases with brittle sharding or complex replication can now simplify their architecture with Spanner, using the tools and skills they already have. Because it’s PostgreSQL, you can be sure that the schemas and queries you write in Spanner are easily portable. And because it‘s Spanner, you can trust that it will grow with your business and development team. Try it out today using a new granular Spanner instance, starting at $65 USD/month, or as low as $40 USD/month with a three-year commitment.

PostgreSQL is the new “API” for operational databases

Enterprises and digital natives alike are standardizing on PostgreSQL as the common “API” for their operational databases. The fast growing project has a proven track record of performance, reliability, and innovation. Its open-source license and thriving ecosystem make it a preferred choice for a wide variety of applications and development teams. As organizations modernize in the cloud, they’re looking to avoid the onerous lock-in associated with last generation’s databases and to leverage the industry skills and tools they already have. An increasing number of them are standardizing on PostgreSQL.

Familiarity for developers

The PostgreSQL interface for Spanner starts with SQL. We’ve implemented a core subset of the PostgreSQL SQL dialect on top of Spanner’s existing distributed relational engine. Unlike other services that manage actual PostgreSQL instances, Spanner uses PostgreSQL-compatible syntax to expose its proven scale-out capabilities. You get PostgreSQL schemas, queries, data types, functions, and metadata that operate at Spanner’s proven scale. This provides familiarity and portability to other environments, but not full PostgreSQL compatibility. The syntax that Spanner does support behaves the same as PostgreSQL itself. However, workloads that lean heavily on things like stored procedures, extensions, triggers, or non-serializable isolation will require rework to run on Spanner. On the other hand, applications that currently use sharding, eventual consistency, or complex replication set-ups to overcome scale up limitations of other databases will likely see significant simplification and lower operational overhead with Spanner. We will continue to invest in compatibility to simplify the transition between PostgreSQL and Spanner.

For applications, we’ve updated our native, open-source clients to easily send PostgreSQL-dialect queries to Spanner databases from Java, Go, Python, Node.js, PHP, Ruby, C#, or C++ via Spanner’s existing globally managed endpoints. To developers, Spanner looks like a simple, single instance database. It manages all of the complexity of load balancing, replication, failover, and even system updates, so your teams can focus on innovation, rather than plumbing. 

In addition to the native Spanner clients, the PostgreSQL interface also supports the popular psql command line tool. This gives developers and administrators a familiar way to run queries, explore metadata, and load data using their existing tools. psql support is enabled by PGAdapter, a lightweight proxy that translates the PostgreSQL wire protocol into Spanner’s native gRPC interface, managing connections and IAM authentication for you. PGAdapter is the foundation on which we will build out support for off-the-shelf PostgreSQL drivers and ORMs, further reducing the effort to take advantage of Spanner’s scale and availability. Stay tuned.

https://storage.googleapis.com/gweb-cloudblog-publish/images/psql-ga.max-900x900.jpg
Using PostgreSQL DDL and DML from psql to create a table and insert data into a Spanner database.

Portability for freedom and flexibility

The schemas and queries that you write against Spanner’s PostgreSQL interface will run mostly without modification in another PostgreSQL environment, either in Google Cloud or elsewhere. This portability is especially important for industries like financial services where emerging regulations and industry guidelines require critical services to demonstrate exit strategies from essential vendors to ensure business continuity. For unique Spanner capabilities, like table interleaving, that don’t have PostgreSQL equivalents, we’ve carefully extended the SQL dialect and documented the differences.

The PostgreSQL interface also improves the options for teams to migrate or upgrade from existing PostgreSQL databases to Spanner. HarbourBridge is an open-source tool that automates schema and data movement from PostgreSQL, MySQL, SQL Server, and DynamoDB to Spanner. We’ve added support for PostgreSQL interface databases as a target for quickly getting started. The PostgreSQL interface also supports PostgreSQL’s built-in COPY command and Dataflow templates for bulk loading from a variety of sources.

Simplicity for greater efficiency 

Spanner is fully managed. When you provision an instance, it comes with storage and compute to handle data, queries, and transactions. Unlike other services, a Spanner instance also includes synchronous replicas without anything else to configure. This is how Spanner scales writes beyond a single machine and provides up to 99.999% availability for interactive workloads. Because downtime is disruptive to your business, scaling a Spanner instance up or down happens without interruption. So does failover, either across zones in a regional deployment or across regions in a multi-region deployment. This means your applications can count on zero recovery time objective (RTO) and zero recovery point objective (RPO). 

The PostgreSQL interface brings this industry leading scalability and availability to the PostgreSQL ecosystem. Even if they don’t run at Google scale today, teams can now grow their databases from a proof-of-concept to a large global presence without disruptive re-architecture at each milestone—start small and pay for only what you use. As an integrated part of Google Cloud, operators can rely on Google’s leading data protection, security, and monitoring infrastructure. Because it’s PostgreSQL, devops teams can move faster using many of the tools and skills they already have. 

Choosing the right interface

For existing Spanner customers, Google is fully committed to continued support and evolution of Google Standard SQL. Spanner’s ANSI SQL dialect and ecosystem are the best choice for teams already familiar with Google Cloud. Along with a wide range of functionality, it provides compatibility with BigQuery’s SQL, allowing teams to reuse queries and concepts. However, teams that have standardized on PostgreSQL elsewhere in their infrastructure should consider Spanner’s PostgreSQL interface first. Administrators configure the database dialect at creation time. A Spanner instance can host multiple databases of either dialect.

Get started today

The PostgreSQL interface for Spanner is an important step in a much longer roadmap to meet developers and operators where they are. Organizations who have standardized on PostgreSQL for their operational workloads can now take advantage of Spanner’s availability and consistency at scale using the skills and tools they already have. 

Get started in minutes with a new database.

Posted in