PostgreSQL (often shortened to “Postgres”) is the world’s most advanced open-source, object-relational database. It’s designed for enterprise-level performance and is valued for its robust features and reliability.
Postgres began in 1986 as an evolution of Ingres, a previous database from the University of California, Berkeley. Since 1994, it has used Structured Query Language (SQL) for queries and transactions—and it has been continuously updated by a community of individual and corporate developers.
This long history of development and use of SQL makes PostgreSQL one of the most popular open source databases worldwide, with every major cloud vendor offering PostgreSQL or PostgreSQL-derived databases as a service.
Sign up for a free trial for any of Google Cloud’s PostgreSQL databases, which include AlloyDB, Cloud SQL for PostgreSQL, and Spanner.
A relational database stores data in structured tables of rows and columns, and maintains information about linked data across multiple tables.
For example, a retail bank might have a table that contains rows of customer information, where each row includes the customer’s name, phone number, and address as columns. There may be a second table that stores transaction information. A relational database would link rows across the two tables, so the bank could track which customer made which transactions.
A ‘query’ is a single operation to request information from the database. A ‘transaction’ is a sequence of operations that can manipulate data in the database. The basic storage operations are commonly referred to as ‘CRUD’, which stands for: create, read, update, and delete.
To optimize retrieval of information from the database, PostgreSQL makes use of indexes—copies of a portion of a table that are reorganized for faster search. Conceptually, these are similar to an index at the end of a book that allows you to find an item quickly without having to scan the entire book.
As a relational database, PostgreSQL uses formal descriptions called “schemas” to describe the structure of the contained data. In particular, a schema is the collection of tables, indexes, and functions in the database, and PostgreSQL supports multiple schemas.
Database professionals are responsible for designing a schema and set of indexes that best represent the data and the way it’s used by application users. They are also in charge of maintenance and operation tasks to keep the data secure and the database operating smoothly.
Since its development at Berkeley, PostgreSQL has remained open source, meaning that the code is completely open for viewing, modification, and distribution.
Developers can use open source databases for their applications with no licensing cost and with full flexibility in deployment, since these databases run on a wide variety of cloud and non-cloud platforms. A community of developers contribute to the improvement and maintenance of the software, improving security and reliability.
The popularity of PostgreSQL has risen in recent years, making it one of the most-used databases worldwide. It offers a number of benefits:
PostgreSQL is used for a wide range of applications due to its flexibility, reliability, and robust feature set. Here are some common uses:
Trusted for highly secure applications, and known for auditability, compliance, and data protection.
PostgreSQL can handle queries across billions of rows, and is commonly used to augment data warehouses and other analytical systems with real-time operational data. In fact, several popular data warehouse products evolved from PostgreSQL.
Scalable, robust, and able to handle high levels of traffic, PostgreSQL is trusted for mobile, web, social media, and other high-volume applications.
PostgreSQL supports geographic data, so applications can calculate the distance between points and perform geospatial calculations for navigation, logistics, and agricultural applications.
PostgreSQL offers high-performance vector search and is commonly used to provide inputs to large language models (LLMs), often extending these models via retrieval augmented generation (RAG). Developers often choose PostgreSQL to build
PostgreSQL is commonly used by organizations for moving legacy apps to a modern, open source platform.
The following sections provide a deeper dive into PostgreSQL's ecosystem. Find comparisons with AlloyDB and Aurora, SQL Server, MySQL, and Oracle, and finally, a look at the differences between fully managed and self-managed PostgreSQL databases.
There are several commercial products on the market with varying levels of compatibility with PostgreSQL. Two of the most popular are AlloyDB from Google Cloud and Aurora from AWS.
AlloyDB runs on any platform and in any cloud, while Aurora runs only on Amazon Web Services (AWS). On the other hand, AlloyDB focuses on PostgreSQL while Aurora offers both PostgreSQL and MySQL engines.
AlloyDB has become a popular choice for enterprises because it:
PostgreSQL is an open source database that runs on most operating systems, while SQL server is a commercial product that runs on Microsoft Windows and Linux. Both are available as managed cloud services from many vendors.
Both systems share many core features, but there are a number of differences. A key advantage of PostgreSQL is that it uses multi-version concurrency control (MVCC) for concurrent processing, so it can process high transaction rates with almost no deadlock. SQL Server is known for high performance and in-memory database capabilities, capabilities that are also provided by AlloyDB.
For a full comparison, read PostgreSQL vs SQL Server.
MySQL is a SQL-based relational database, while PostgreSQL is an object-relational database. Although they are both open source, PostgreSQL follows licensing that allows commercial distribution. The MySQL open source project is sponsored by Oracle.
PostgreSQL scales by adding processes, which historically is a good approach for reliable applications. PostgreSQL’s extension mechanism makes it a generally more popular platform for community contributions.
MySQL scales by adding threads, which is typically good for small-scale, resource-light applications.
The choice often comes down to personal preference and the experience set of available skilled developers.
A few technical differences between PostgreSQL and MySQL:
PostgreSQL
MySQL
PostgreSQL and Oracle are both popular relational databases that support SQL and use comparable procedural languages (PL/SQL in Oracle’s case). Both are valued for their scalability and security.
Oracle is used by enterprises of all sizes to drive mission-critical applications, and is known for its availability and support for advanced features such as clustering.
PostgreSQL provides similar features and functionality to Oracle—including disaster recovery, high performance, and built-in replication. Enterprises choose PostgreSQL as a more open, cost-effective alternative to Oracle.
As with all databases, self-managing requires technical experience within your team. This includes knowledge about configuring and maintaining the architecture, scaling jobs, and general database management skills such as performing upgrades, backups, security maintenance, disaster recovery, and installing patches. Development teams increasingly prefer a fully managed database so they can focus on their applications.
Fully managed databases:
However, if you require full control over your database environment due to unique application needs, then a self-managed database enables that flexibility.
Extensions enable you to expand and tailor the functionality of your database to your specific requirements. PostgreSQL offers comprehensive extension support, with extensions behaving just like built-in functions—including those developed externally.
Some commonly used extensions are:
PostgreSQL supports both basic data types and advanced data types not commonly found in other databases, including boolean, number, integer, timestamp, array, and more. Developers can also create their own data types.
Its default procedural language is an extension of pgSQL (PL/pgSQL), with procedural language extensions of Tcl, Perl, and Python included in the standard distribution (written as PL/Tcl, PL/Perl, and PL/Python). These loadable procedural languages enable the coding language to be used to create functions and trigger procedures.
Many more languages are supported through extensions, including Java, Ruby, C, C++, Delphi, and JavaScript.
PostgreSQL enables you to code in multiple languages without recompiling the database, a key benefit for developers.
Yes, PostgreSQL has been ACID compliant since 2001.
ACID (atomicity, consistency, isolation, durability) is a set of properties that describe how transactional databases ensure the data is valid. ACID compliance guarantees data quality even in the case of a network outage or hardware failure, and enables reading and writing at the same time without data loss or corruption. These principles are critically important to applications in many industries, including finance and healthcare.
Say, for example, a banking application is transferring a balance between two accounts within the database. If there’s an outage or failure in the middle of the transaction, an ACID-compliant database ensures that the money doesn’t simply disappear or is credited more than once—the account balances always remain valid.
Start building on Google Cloud with $300 in free credits and 20+ always free products.