What is PostgreSQL?
PostgreSQL is an object-relational database for applications that need SQL transactions, relational constraints and extensible data types. It also supports JSON documents and an extension ecosystem including geospatial tools. Teams can run it themselves or buy a managed service from a hosting provider; the database licence does not include somebody operating backups and upgrades for them.
Who is PostgreSQL for?
Application teams needing a relational foundation with flexible queries, document fields and extensions
Evaluate the data rules alongside the operating model
PostgreSQL, also known as Postgres, provides SQL transactions, constraints and extensible types. Choose a deployment around the application, supported version, extensions and responsibility for upgrades and recovery.
Compare PostgreSQL and MySQL for the broader database choice. Our SQLite profile covers a different embedded operating model and its own foreign-key example.
PostgreSQL features
The core capabilities to consider for your workflow.
- SQL transactions and relational constraints
- JSON and JSONB data types
- Custom functions and extensions
- Replication and point-in-time recovery
- Row-level security
Four checks we actually ran on PostgreSQL 17.11
On 17 October 2026, we used a fresh temporary PostgreSQL cluster with fictional TEMP tables and reserved example.invalid email strings. The server had TCP disabled and was stopped and removed after the run.
Ordinary UNIQUE
Two NULL emails were accepted. A repeated non-null email and a repeated empty string each raised 23505. The table retained 4 rows, including 2 NULLs and 1 empty string.
UNIQUE NULLS NOT DISTINCT
The first NULL was accepted. The second raised 23505, leaving 1 row. The separate NOT NULL text column rejected NULL but accepted an empty string.
Full transaction rollback
A duplicate insert raised 23505. The next query raised 25P02. After full ROLLBACK, 0 rows remained.
A separate savepoint transaction
ROLLBACK TO SAVEPOINT recovered from the duplicate failure. A later valid insert and COMMIT retained IDs 1 and 3, 2 rows in total.
The constraint reference explains the default NULL treatment. The PostgreSQL 15 release notes document NULLS NOT DISTINCT. Our observed version is 17.11; these checks do not establish hosting performance, concurrency or recovery quality.
PostgreSQL pricing
Free self-managed database
The database software has no seat or database licence charge. Budget separately for infrastructure, managed hosting, backups and support.
Calculate the cost of your quote →Free access & evaluation
PostgreSQL is available without a licence fee under the PostgreSQL License. Hosting and operational support are separate.
Separate the software licence from the service bill
The PostgreSQL License permits use of the core software without a licence fee. Infrastructure, a managed provider, support and the work of maintaining and recovering the service need their own budget.
Check the proposed deployment’s version and required extensions, then price its resources and operational scope. A small local constraint test is not a production capacity estimate.
Before you choose PostgreSQL
Self-managed deployments require patching, monitoring and tested recovery
Managed-provider extension and version support varies
Changing from another SQL engine still requires application compatibility work
Read the first error before retrying
Our explicit transaction failed on a duplicate value before the next query reported an aborted transaction. PostgreSQL’s SQLSTATE reference distinguishes the unique violation from the later transaction-state error. Retain both when investigating the application.
The transaction tutorial notes that client libraries can manage transaction boundaries automatically. In this fixture, a full rollback discarded earlier uncommitted work. A pre-existing savepoint in a separate transaction let us discard the failed part and continue. Check the actual driver or ORM instead of assuming it follows the same explicit sequence.
Download and reproduce the example
Download the PostgreSQL example kit
The kit contains the Python runner, companion psql script, recorded JSON results and instructions. It requires installed PostgreSQL 15+ server tools and Python on a POSIX system.
The runner accepts no existing database connection, creates its own peer-authenticated private Unix-socket cluster and checks the observed rows and error codes. It confirms shutdown before removing its own files. Run the provided runner with both code files together.
Only the supplied synthetic constraints and explicit transactions were tested. No existing database, application, production credentials or hosted account was accessed.
Explore PostgreSQL in more detail
Take a closer look at the decisions behind this product.
Compare PostgreSQL
Amazon Aurora vs PostgreSQL
Compare Aurora PostgreSQL-Compatible with a PostgreSQL deployment for application compatibility, extensions, operating ownership, recovery and the complete bill.
Read the comparisonPostgreSQL vs MySQL
PostgreSQL vs MySQL: compare SQL and JSON workflows, licensing, extensions, application compatibility, hosting and recovery requirements.
Read the comparisonMongoDB vs PostgreSQL
MongoDB vs PostgreSQL: compare document and SQL modelling, JSON, transactions, hosted free access, software licences and migration requirements.
Read the comparisonExplore the individual profiles
PostgreSQL FAQs
Is PostgreSQL free to use?
The core database is available without a licence fee under the PostgreSQL License. Hosting, managed services, support and operating the database have separate costs. A free software licence is different from a hosted free-plan allowance.
Why does PostgreSQL UNIQUE allow multiple NULL values?
By default, NULL values are not treated as equal for uniqueness. In our PostgreSQL 17.11 test, ordinary UNIQUE accepted two NULL emails but rejected a repeated non-null email. The fixture retained 2 NULL rows; it used one nullable text column.
How can PostgreSQL allow only one NULL in a unique column?
PostgreSQL 15 introduced UNIQUE NULLS NOT DISTINCT. In our single-column example, the first NULL was accepted and the second raised SQLSTATE 23505. This is different from NOT NULL, which rejects NULL altogether. Review existing data before changing a real constraint.
Does PostgreSQL NOT NULL reject an empty string?
Not in our text-column example. NULL raised SQLSTATE 23502, while an empty string was accepted. NULL and an empty text value are different. A requirement for nonblank content needs an appropriate additional validation rule.
Why does PostgreSQL report 25P02: current transaction is aborted?
In our explicit transaction, a duplicate insert raised 23505. The next query raised 25P02 until the transaction was rolled back. Inspect the earlier error and the client’s transaction handling; repeating the query alone did not repair this fixture’s transaction.
Does a PostgreSQL ROLLBACK discard earlier valid inserts in the transaction?
Yes in our explicit transaction example. After a valid insert followed by a duplicate failure, a full ROLLBACK left 0 rows. Those changes were uncommitted; this does not describe undoing data committed by an earlier transaction.
Can a PostgreSQL savepoint preserve work before a failed insert?
Yes. In a separate transaction, our savepoint preceded a duplicate insert. ROLLBACK TO SAVEPOINT allowed a new valid insert, and COMMIT retained 2 rows with IDs 1 and 3. It required that pre-existing savepoint; a full rollback had a different result.


