Data

How to migrate from Oracle to PostgreSQL

Migrating from Oracle to PostgreSQL in 2026: licensing costs, real TCO, PL/SQL conversion, ora2pg tooling and CDC, the full five-phase method.

October 4, 20218 min
How to migrate from Oracle to PostgreSQL
TL;DR
  • Migrating from Oracle to PostgreSQL answers three motivations: cutting costs, gaining multi-cloud flexibility, and benefiting from customisability through extensions (pgvector, PostGIS, TimescaleDB).
  • Oracle's TCO bundles per-core licensing, paid options (RAC, Active Data Guard, Partitioning) and annual support at roughly 22% of the license price; documented migrations report 40-70% savings over five years.
  • The method unfolds in five phases: dependency assessment, schema design with PL/SQL-to-PL/pgSQL conversion, configuration testing, performance testing, and data migration.
  • Tools such as ora2pg, pgloader, Ora_migrator and Orafce automate most of the schema and business-logic conversion.
  • For minimal-downtime migrations, change data capture continuously synchronises Oracle and PostgreSQL up to the final cutover.

Why migrate from Oracle to PostgreSQL in 2026

In 2026, the question is no longer whether PostgreSQL is ready for critical production workloads, but when to schedule the switch. Repeated increases in Oracle licensing costs, ever more frequent compliance audits, and the gradual folding of once-free features into paid options are pushing many technical leadership teams to document an exit path. On the other side, PostgreSQL has matured significantly: recent releases close most of the historical functional gaps, native partitioning, logical replication, query parallelism, and the managed-service ecosystem (Amazon Aurora PostgreSQL, Google AlloyDB, Azure Database for PostgreSQL Flexible Server, or specialists such as Crunchy Data and EDB) drastically cuts the operational burden.

Three motivations show up consistently across migration projects. Cost reduction comes first: PostgreSQL is open source and free to install, whereas Oracle charges separately for partitioning, high availability (RAC, Data Guard) or diagnostics features. Flexibility comes next: PostgreSQL integrates natively with every major cloud provider, which avoids vendor lock-in and eases multi-cloud or hybrid architectures. Customisability comes last: the PostgreSQL extension ecosystem, pgvector for vector search and AI use cases, PostGIS for geospatial data, TimescaleDB for time series, enriches the database without an additional license fee.

But an Oracle-to-PostgreSQL migration is never a simple export-import. It touches the schema, the business logic embedded in the database, operational habits and sometimes the application architecture itself. Hence the need for a phased method, detailed in the sections below.

The real total cost of ownership: Oracle versus PostgreSQL

Before launching a technical project, it pays to precisely quantify what the status quo actually costs. The calculation goes well beyond the sticker price of the license.

Oracle licensing, options and support

The Oracle Database Enterprise Edition licensing model is billed per processor core, with a multiplying factor depending on the hardware architecture. On top of that base come separately sold options: Partitioning, Real Application Clusters (RAC), Active Data Guard, Advanced Security, Diagnostics and Tuning Pack. Annual support typically runs at around 22% of the license price, renewed every year with no room to negotiate. The shift in Java SE licensing, now calculated per employee rather than per install, has also driven up many organisations' Oracle bills without any change in application footprint. Compliance audits, dreaded by CIOs, add a financial risk that is hard to budget for in advance.

The real TCO of managed PostgreSQL

PostgreSQL itself is free, but its real TCO factors in infrastructure, optional support from a specialised vendor (EDB, Crunchy Data, Percona) or a managed-service subscription, plus the team's ramp-up in skills. Reports from migration projects run over recent years show a five-year TCO reduction of between 40% and 70%, depending on how many Oracle options were in use beforehand. The gap widens further when the organisation relied on RAC or Active Data Guard, whose PostgreSQL equivalents, streaming replication, Patroni, clustering extensions, remain open source.

Phase 1: assessment and dependency mapping

The first phase objectively gauges the complexity of the project before committing to it. It means inventorying the application estate: number of schemas, data volumes, PL/SQL queries, packages, triggers, jobs scheduled via DBMS_SCHEDULER, dblinks to other databases, and the use of proprietary features such as CONNECT BY hierarchical queries, the MERGE statement, or advanced analytic functions. Every proprietary element identified represents a potentially costly conversion point.

Assessment tools automate a good part of this work. The ora2pg audit report evaluates overall compatibility and estimates, in person-days, the effort needed to convert the business logic. Schema-conversion tools offered by cloud providers complement this analysis for architectures targeting a managed hosting option. The deliverable from this phase is a complexity score per application, used to prioritise the migration order rather than switching everything at once.

Phase 2: target schema design and business-logic conversion

Schemas, roles and tablespaces

A first structural difference: in Oracle, a schema is inseparable from a user, whereas in PostgreSQL schemas are namespaces independent of roles, allowing finer-grained organisation. The tablespace strategy also needs revisiting, along with identifier case, PostgreSQL folds unquoted names to lowercase by default, unlike Oracle which uppercases them, and naming conventions to avoid ambiguity once the conversion is done.

Converting PL/SQL to PL/pgSQL

The embedded business logic requires the most meticulous work. NUMBER types become numeric, VARCHAR2 becomes varchar or text, DATE becomes timestamp. Oracle packages have no direct equivalent and typically translate into a dedicated schema grouping PL/pgSQL functions. Cursors, exceptions and %ROWTYPE attributes have close but not identical syntax equivalents. The Orafce extension bridges part of the gap by re-implementing common Oracle functions, DECODE, date-manipulation functions, directly usable in PostgreSQL, which limits manual rewriting.

The tooling: ora2pg, pgloader, Ora_migrator

Several tools complement one another depending on the nature of the project. Ora_migrator, built on the postgres_fdw extension, allows a fully SQL-driven conversion from within PostgreSQL, which suits teams more comfortable with the target ecosystem. Ora2pg remains the open-source reference for extracting the schema, the data and the PL/SQL code in a single pass. Pgloader speeds up data loading once the schema is in place. For migrations to managed cloud hosting, database migration services natively embed change data capture, which simplifies coordinating schema conversion with data synchronisation.

Phase 3 and 4: configuration and performance testing

Functional testing and regression checks

Configuration testing loads an identical dataset into both databases, then runs the same functional workloads to compare results field by field. Discrepancies caught at this stage, different numeric rounding, NULL handling in aggregations, string sorting under different locales, are far cheaper to fix here than after the switch to production. Automated diff scripts, or dedicated data-testing frameworks, industrialise this comparison at scale.

Tuning and load testing

Performance testing then tackles behavioural differences between the two engines. The PostgreSQL planner reasons differently from Oracle's cost-based optimiser; statistics need to be regenerated with ANALYZE, index types adapted (B-tree, GIN for text or JSON, BRIN for large sorted tables), and memory parameters (shared_buffers, work_mem, effective_cache_size) sized for the real workload. Tools such as pgbench or HammerDB let teams replay representative load scenarios and confirm response times stay acceptable before the final cutover.

Phase 5: data migration strategies

Snapshot and parallel snapshot

For smaller databases, a full snapshot, a single export followed by an import within one maintenance window, remains the simplest approach. On larger volumes, a parallel snapshot splits the migration into batches processed simultaneously, typically table by table or by key range, which shortens the required downtime window accordingly.

Logical replication and change data capture

When service disruption must be minimised, change data capture takes over. The principle: continuous replication propagates, in near real time, changes made on the Oracle side to the target PostgreSQL database, while the old database keeps serving production. The final cutover then reduces to switching a connection string once both databases are in sync, bringing perceived downtime down to a few minutes. This choice means selecting the hosting target early, since CDC mechanisms differ between a self-hosted PostgreSQL and a managed service.

Database-as-a-Service (DBaaS)
Related readDatabase-as-a-Service (DBaaS)Database-as-a-Service (DBaaS) lets you run a database without managing it: managed hosting, usage-based billing, scalability and delegated security.Read the article

High availability and post-cutover operations

Migration doesn't stop at cutover. Once production has switched over, the resilience mechanisms Oracle provided through RAC or Active Data Guard need rebuilding: synchronous or asynchronous streaming replication, automatic failover with tools like Patroni, connection pooling with PgBouncer to absorb load, and point-in-time recovery backups via pgBackRest or Barman.

High availability PostgreSQL patterns
Related readHigh availability PostgreSQL patternsPatroni, PgPool-II, PAF, CloudNativePG: a 2026 comparison of PostgreSQL high-availability patterns, replication, automatic failover, RTO/RPO and best practices.Read the article

Tuning isn't a one-shot exercise either. The first weeks in production often surface queries that behaved well under Oracle but need an index or a rewrite under PostgreSQL. A continuous observation cycle, backed by pg_stat_statements and monitoring dashboards, lets the configuration be adjusted on the fly rather than frozen at go-live.

PostgreSQL performance best practices
Related readPostgreSQL performance best practicesPostgreSQL 18 in production: memory, NVMe storage, EXPLAIN ANALYZE, PgBouncer/PgCat pooling, autovacuum, partitioning, replication and high availability. Full 2026 guide.Read the article

The Adservio approach: running the migration as a project, not a copy job

At Adservio, we treat an Oracle-to-PostgreSQL migration as a project in its own right, never as a mere copy of data. It is known to be time-consuming and costly: that is precisely why the assessment phase and upfront planning are decisive, notably to avoid copying historical data whose real production value is nil.

Our conviction: a successful migration is prepared phase by phase, accounting for the real differences between the two systems rather than hunting for a mechanical equivalent to every Oracle feature. We support your teams throughout the process, assessment, conversion, testing, cutover, operations, and transfer the technical know-how so they can sustainably run their new PostgreSQL database on their own.

PostgreSQLDataOracleMigrationDatabaseOpen sourceOra_migratorCloudPL/pgSQLHigh availability

GET THIS ARTICLE

Download the full article as a PDF to read offline or share it.

SHARE THIS ARTICLE

On LinkedIn, X or by email, or just copy the link.

STAY POSTED

Get our next analyses and field notes straight to your inbox.

TALK TO AN EXPERT

Put these ideas into practice

Talk to our engineers about how this applies to your platform, your data and your teams.

By submitting this form, you agree to our privacy policy.

Frequently Asked Questions

For three main reasons: cutting costs (per-core licensing, paid options and support fees make Oracle's TCO high compared with open-source PostgreSQL), gaining flexibility through native cloud integration that avoids vendor lock-in, and benefiting from extensive customisability via extensions such as pgvector, PostGIS or TimescaleDB.

Assessment and dependency mapping, target schema design with PL/SQL-to-PL/pgSQL conversion, configuration testing, performance testing, and finally the actual data migration.

By relying on change data capture: continuous replication keeps Oracle and PostgreSQL in near-real-time sync while production keeps running on the old database, until a final cutover that takes only a few minutes.