PostgreSQL
- Pronunciation
- POHST-gres-kyoo-EL
In short
PostgreSQL is a free, open-source relational database known for reliability, strict standards support and extensions, and widely used for web applications.
What is PostgreSQL?
PostgreSQL, often just called Postgres, grew out of the POSTGRES research project at the University of California, Berkeley, which began in 1986. It is a relational database: data lives in tables with rows and columns, and you read and change it with SQL. It is developed by a global community and released under a permissive license, so anyone can use it for free, including in commercial products.
Postgres is known for doing things correctly. Transactions follow the ACID rules, so a group of changes either all happen or none do, and multiversion concurrency control (MVCC) lets many users read and write at the same time without blocking each other. It supports advanced SQL features such as window functions, common table expressions and many index types.
It is also unusually extensible. Columns can hold JSON in a binary format called JSONB that can be indexed and queried, so one database can serve both relational and document-style data. Extensions add whole new abilities: PostGIS for maps and geography, pgvector for AI embeddings, and full-text search is built in.
A common misconception is that PostgreSQL is only for very large or complex projects. It runs just as well behind a small website, and most cloud providers offer it as a managed service. Compared with MySQL, it is usually described as stricter and richer in features, while both are mature, fast and widely supported.
Key takeaways
- PostgreSQL is a free, open-source relational database that uses SQL.
- Transactions are ACID, and MVCC lets readers and writers work at the same time.
- JSONB columns let it store and index document-style data.
- Extensions such as PostGIS and pgvector add new capabilities.
- It is offered as a managed service by most cloud providers.
Example
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
price NUMERIC(10, 2) NOT NULL,
attrs JSONB -- flexible, document-style data
);
INSERT INTO products (name, price, attrs)
VALUES ('Desk lamp', 39.90, '{"color": "black", "watts": 8}');
-- Query inside the JSON
SELECT name FROM products WHERE attrs->>'color' = 'black';Readers ask
Is PostgreSQL free?
Yes. It is released under the PostgreSQL License, a permissive open-source license, so you can use, change and ship it, also in commercial software, without paying.
What is the difference between PostgreSQL and MySQL?
Both are open-source relational databases. PostgreSQL is usually seen as stricter about standards and richer in advanced features and extensions, while MySQL is known for simplicity and its long history in web hosting. Either is a solid choice for most applications.
Can PostgreSQL store JSON?
Yes. The JSONB type stores JSON in a binary form that can be indexed and queried with operators, so PostgreSQL can handle many document-database use cases.
Often compared
- PostgreSQL vs MySQLBoth are open-source relational databases: PostgreSQL is known for advanced SQL, extensibility and strictness, MySQL for simplicity, speed and wide adoption.
- MongoDB vs PostgreSQLPostgreSQL keeps data in fixed-schema tables and joins them with SQL, while MongoDB stores flexible JSON-like documents and was built to shard across servers.
See also
- Relational DatabaseDatabases, p. 38A relational database stores data in tables of rows and columns, links those tables through keys, and lets you query and combine the data with SQL.
- SQLDatabases, p. 40SQL is the standard language for working with relational databases, used to create tables and to insert, query, update, and delete the data stored in them.
- ACIDDatabases, p. 1ACID is a set of four guarantees, atomicity, consistency, isolation, and durability, that keep database transactions reliable even when errors or crashes occur.
- TransactionDatabases, p. 47A transaction is a group of database operations that succeed or fail as a single unit, so the data is never left in a half-finished, inconsistent state.
- MySQLDatabases, p. 27MySQL is a popular open-source relational database queried with SQL, long known as the database behind WordPress and the classic LAMP web stack.
- JSONBackend & APIs, p. 25JSON is a lightweight, text-based format for storing and exchanging structured data as key-value pairs and lists, readable by both humans and machines.
- SupabaseDatabases, p. 45Supabase is an open-source backend platform built on PostgreSQL that gives an app a database, authentication, storage, real-time updates and instant APIs.
Spotted a mistake or something missing on this page?Suggest an edit