PostgreSQL

From WikiTech, the encyclopedia of technology

Technology · Systems & Infrastructure · 5 min read · 922 words · Updated

PostgreSQL
Technology
Original authorMichael Stonebraker (POSTGRES)
Initial release1989 (POSTGRES); 1996 (PostgreSQL)
Written inC
Websitepostgresql.org

PostgreSQL is a relational database management system that supports SQL and many extensions such as JSON types, custom data types and procedural languages.

History

Its origin is the POSTGRES project at the University of California, Berkeley, led by Michael Stonebraker starting in 1986. SQL support was added in 1994-1995 and the project was renamed PostgreSQL in 1996.

Architecture

PostgreSQL uses a process-per-connection model. Multi-version concurrency control (MVCC) lets readers and writers avoid blocking one another. Durability is provided by write-ahead logging (WAL), which also supports replication and point-in-time recovery.

Key mechanisms

The query planner estimates the cost of alternative plans using statistics. Index types include B-tree, hash, GiST, GIN and BRIN. Extensions such as PostGIS and pgvector add geospatial and vector search features.

Adoption

PostgreSQL is used as a primary database for web applications, analytics and geospatial systems. Under the CAP Theorem, a single-node deployment is consistent, while replicated setups must choose behaviour during partitions.

Relational model and SQL

PostgreSQL stores structured data in relations, commonly presented as tables containing rows and columns. SQL provides a declarative way to describe queries, constraints and data changes. A user specifies what information is required, while the query planner chooses how to retrieve it. This separation lets the database use indexes, join algorithms and statistics to find an efficient execution plan without forcing application code to implement each storage operation.

PostgreSQL supports transactions with atomicity, consistency, isolation and durability properties. A transaction groups several operations into a unit: either the changes are committed or they are rolled back. Constraints such as primary keys, foreign keys, unique rules and check expressions help preserve data integrity at the database layer rather than relying entirely on application code.

MVCC and concurrency

PostgreSQL uses multi-version concurrency control (MVCC). Instead of forcing every reader to wait for a writer, the system can retain multiple row versions so a transaction sees a consistent snapshot. This improves concurrency for many workloads, but old row versions must eventually be cleaned up. The vacuum process reclaims space and maintains visibility information; poorly managed vacuuming can lead to table bloat and performance problems.

Isolation levels control how concurrent transactions observe changes. The default READ COMMITTED level gives each statement a fresh snapshot, while REPEATABLE READ and SERIALIZABLE provide stronger guarantees with different performance and retry considerations. Applications using stronger isolation levels must be prepared to handle serialization failures by retrying transactions where appropriate.

Storage, indexes and recovery

PostgreSQL uses write-ahead logging (WAL) to record changes before the corresponding data pages are written. WAL supports crash recovery and forms the basis for physical replication and point-in-time recovery. Administrators can combine base backups with archived WAL segments to restore a database to a chosen point, provided the backup chain is complete and tested.

Indexes accelerate queries by providing alternative access paths. B-tree indexes are suited to many equality and range queries. GIN can support values such as arrays and text-search documents, GiST supports extensible search structures, and BRIN can be useful for very large tables whose physical order correlates with indexed values. Indexes consume storage and add work to writes, so they should be selected based on measured query patterns.

Extensibility and ecosystem

PostgreSQL supports user-defined types, functions, operators and extensions. PostGIS adds spatial data types and geospatial operations. Other extensions provide monitoring, specialised indexing and additional application capabilities. The extension model has helped PostgreSQL serve workloads that might otherwise require a separate database product.

Its SQL support and transaction behaviour make it a common choice for web applications, financial records, internal business systems and analytics. It can also store JSON documents, but that does not make it a document database in the same sense as specialised systems. Relational constraints and joins remain useful when an application needs a clear data model and dependable consistency.

Operations and trade-offs

A production PostgreSQL service requires thoughtful capacity planning. Administrators need to monitor query latency, connections, memory, disk usage, replication lag and backup status. Connection pooling can reduce overhead when applications create many short-lived connections. Replication improves read scaling or availability, but it introduces operational choices about failover, consistency and recovery objectives.

PostgreSQL's flexibility can become a challenge if schemas, indexes and extensions are added without a clear maintenance plan. Upgrades require testing for compatibility and performance changes. The database is powerful, but it cannot replace application-level authorisation, input validation or a sound backup strategy.

Community and release practices

PostgreSQL is developed by an international community of contributors, reviewers, extension authors and service providers. Major releases introduce features and improvements, while minor releases focus on bug fixes and security corrections. Administrators should read release notes and test upgrades against representative workloads before changing production systems. The project provides documentation for each supported major version, which is important because behaviour and available features can differ between versions. A mature database deployment therefore includes a planned upgrade cycle as part of normal operations.

Editorial connections and engineering implications

PostgreSQL uses multi-version concurrency control (MVCC), allowing readers to observe consistent snapshots while writers create new row versions. Old versions must eventually be reclaimed, so vacuum activity and long-running transactions affect storage health. Indexes can speed up selected queries but also consume space and add work to inserts and updates. Their usefulness should be checked against representative workloads rather than assumed.

The query planner estimates the cost of possible execution plans using statistics. Stale statistics or unusual data distributions can lead to poor plans, so performance work includes inspecting query plans, schema, indexes, cache behaviour and concurrency. Production reliability also requires tested backups, restoration procedures, replication monitoring and planned upgrades. In a distributed application, a local database transaction cannot make a multi-service workflow atomic; this links PostgreSQL to service architecture, consistency trade-offs and safe retries.

See also

  • CAP Theorem – A result stating that a distributed data store cannot simultaneously guarantee consistency, availability and partition tolerance.
  • Linux – A family of open-source, Unix-like operating systems based on the Linux kernel.
  • C (programming language) – A general-purpose, statically typed systems programming language created at Bell Labs in the early 1970s.
  • Git – A distributed version control system that tracks changes to files as a graph of snapshots.
  • Big-O Notation – A notation describing how the resource use of an algorithm grows as the input size grows.
  • Idempotency – The property of an operation that produces the same result whether it is applied once or many times.
  • JSON – A lightweight text format for structured data based on JavaScript object syntax.
  • Kubernetes – An open-source system for automating deployment, scaling and management of containerised applications.

References

  1. ↑ PostgreSQL Documentation (postgresql.org)