What is PostgreSQL?

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.

What is a relational database?

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. 

PostgreSQL basics

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.

PostgreSQL is an open source database

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.

PostgreSQL advantages

The popularity of PostgreSQL has risen in recent years, making it one of the most-used databases worldwide. It offers a number of benefits:

  • Reliable and secure. PostgreSQL is highly fault-tolerant, maintaining data durability and maximizing uptime. It supports a strong authentication and authorization model, as well as several encryption methods—including end-to-end data encryption using SSL.
  • High performing. PostgreSQL stores data in a structured way that allows it to efficiently insert, delete, and modify data. It’s also efficient for lookups and joins. Additionally, PostgreSQL can scale with multiple CPUs in parallel, speeding queries even further. 
  • Compliant. Given their high compliance with the SQL standard, PostgreSQL databases are easy for both building apps and migrating existing ones. They are also ACID compliant, which means that your data is valid even amid hardware, software, or network disruptions.
  • Highly extensible. PostgreSQL supports a wide range of data types (including advanced and user-created types), multiple coding languages, and the ability to write custom functions. It also has an extension mechanism for adding new functionality.
  • Simple to monitor. PostgreSQL provides several statistics to support collection and reporting of server activity. Several external tools to monitor database activity and analyze performance are available.

What is PostgreSQL used for?

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.

PostgreSQL comparisons

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:

  • Uses multiple layers of caching throughout the stack, including an ultra-fast cache at the database layer 
  • Has a built-in columnar engine that accelerates analytical queries
  • Uses ML-enabled systems to simplify management tasks like vacuum, storage, and memory management
  • Includes AlloyDB AI, a platform for building gen AI apps with high-performance vector search, vector embeddings , and natural language support within the database
  • Emphasizes transparent and predictable pricing, with pay-as-you-go storage and no I/O charges

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

  • Supports complex data types and an extension mechanism
  • Supports MVCC, allowing data modification with almost no deadlock
  • Supports a vast array of data types that are highly extensible
  • Supports a rich variety of index types including B-Tree, HASH, GiST, and GIN
  • Implements a VACUUM process for garbage collection

MySQL

  • Focuses on traditional relational database concepts
  • Supports MVCC, depending on the storage engine
  • Supports a standard set of data types
  • Offers a limited set of indexes
  • Uses dedicated purge threads

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:

  • Are easy to try and simple to use
  • Scale simply or even automatically
  • Offer automated backups and upgrades
  • Deliver built-in high availability and disaster recovery

However, if you require full control over your database environment due to unique application needs, then a self-managed database enables that flexibility.

PostgreSQL extension support

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:

  • PostGIS. Supports storing, indexing, and querying geospatial data. Used for a variety of geospatial applications, including navigation.
  • pgvector. Enables storing, indexing, and querying vectors and running vector similarity searches. Used for generative AI and natural language processing.
  • pglogical. Replicates data robustly using logical replication. Used for replicating between PostgreSQL databases and supports granular table-level replication.

PostgreSQL data types

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.

What languages does PostgreSQL support?

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.

Is PostgreSQL ACID compliant?

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.

Take the next step

Start building on Google Cloud with $300 in free credits and 20+ always free products.

Google Cloud
  • ‪English‬
  • ‪Deutsch‬
  • ‪Español‬
  • ‪Español (Latinoamérica)‬
  • ‪Français‬
  • ‪Indonesia‬
  • ‪Italiano‬
  • ‪Português (Brasil)‬
  • ‪简体中文‬
  • ‪繁體中文‬
  • ‪日本語‬
  • ‪한국어‬
控制台