PostgreSQL to Databricks Migration: How to Move Postgres to the Lakehouse and Lakebase

 & LatentView Analytics

LatentView Analytics has been helping enterprises make data-driven decisions for nearly 20 years. The company brings deep expertise in data engineering, business analytics, GenAI, and predictive modeling to 50+ Fortune 500 clients across tech, retail, financial services, and CPG. A publicly traded company serving the US, India, Canada, Europe, and Singapore, LatentView is recognized in Forrester's Customer Analytics Service Providers Landscape.

SHARE

Table of Contents

This guide helps data and technology leaders plan a PostgreSQL to Databricks migration, from choosing the right approach and configuring ingestion to converting PL/pgSQL, moving applications to Lakebase and retiring legacy servers.

Migrating from PostgreSQL to Databricks involves moving analytical or operational workloads from a relational database to the Databricks Data Intelligence Platform, with Delta Lake and Unity Catalog for analytics and Lakebase, Databricks’ managed Postgres, for transactional applications.

Key Takeaways

  • PostgreSQL to Databricks migration splits Postgres workloads by purpose: analytics moves to Delta Lake, and transactional databases can move to Lakebase
  • Lakeflow Connect replicates PostgreSQL changes through logical replication, so the source stays live during the migration
  • Replication slots need active monitoring, since an unread slot keeps WAL on the source and can fill its disk
  • JSONB, arrays and timestamps without time zones arrive in Databricks as strings and need explicit conversion
  • Lakebase keeps Postgres compatibility for applications while synced tables connect it to the lakehouse

Choosing the Right PostgreSQL to Databricks Migration Approach

The right approach depends on what each PostgreSQL database does today: analytics workloads re-platform to Delta Lake, while application databases can move to Lakebase.

PostgreSQL can serve applications or analytics, and the two need different migrations.

ApproachWhen It FitsWhat Changes
Re-platform analytics to Delta LakePostgres used for reporting, aggregation or data scienceTables become Delta tables, PL/pgSQL becomes Databricks SQL or Python
Move applications to LakebasePostgres serving transactions for an applicationConnection strings and some extensions; SQL stays Postgres
Replicate and keep PostgresApplications that must stay on their current hostChanges stream into Delta tables through Lakeflow Connect
Federate during the transitionReports that need Postgres data before migration completesNothing moves; Databricks queries Postgres in place

These approaches can be combined across a PostgreSQL estate.

Databricks recommends phasing migrations by risk, business impact and readiness instead of a big-bang cutover.

Where PostgreSQL Workloads Land on Databricks: Delta Lake vs Lakebase

Delta Lake suits analytical queries across large data volumes, while Lakebase suits low-latency reads and writes from applications, and synced tables connect the two.

WorkloadBest Landing PlaceWhy
Reporting databases and data martsDelta LakeColumnar storage and elastic compute handle large scans
ETL staging schemasDelta Lake with Lakeflow pipelinesDeclarative pipelines add incremental processing and built-in data quality checks
Application databasesLakebaseStandard Postgres, so application SQL carries over
Feature stores and agent memoryLakebaseLow-latency lookups for models and AI agents
Historical archivesDelta LakeCloud object storage with time travel

Lakebase is a fully managed Postgres service built into Databricks and generally available on AWS since January 2026 and on Azure since March 2026, with Google Cloud following in October 2026. It supports Postgres 16, 17, 18 and 19, with 18 as the default and Postgres 19 added in November 2026.

Compute autoscales and can scale to zero, branches give teams copy-on-write environments for testing, and read replicas and high availability come built in.

How Lakebase Synced Tables Connect Postgres and the Lakehouse

Lakebase reduces the need for nightly exports between an application database and the warehouse. Two features carry data across:

  • Synced tables: Unity Catalog tables, such as customer scores or product recommendations computed in Delta Lake, sync into Lakebase so applications read them with low latency
  • Change Data Feed: row-level changes in Lakebase land as Delta tables in Unity Catalog for analytics and audit, currently in Public Preview

The result is one governed loop: applications write to Lakebase, analytics run on Delta Lake, and results flow back to the application without custom pipelines.

Synced tables run in three modes: snapshot for full periodic copies, triggered for refreshes on demand or on a schedule, and continuous for streaming updates.

A product catalog that changes nightly can use snapshot mode, while a fraud score that applications check on every order needs continuous mode, so each table pays only for the freshness it needs.

Core PostgreSQL to Databricks Migration Phases

A PostgreSQL migration runs through five phases, from discovery and target design to data movement, validation and decommissioning, repeated in waves for each database group.

Discovery and Workload Assessment

PostgreSQL catalogs describe the estate in detail. The inventory should capture:

  • Databases, schemas, table sizes and growth rates from the system catalogs
  • PL/pgSQL functions, procedures, triggers and views
  • Installed extensions, such as PostGIS, pg_trgm or pgvector
  • Scheduled work in pg_cron or external schedulers
  • Query statistics from pg_stat_statements, which show the heaviest and most frequent queries
  • Every application, BI tool and ETL process that connects

Lakebridge conversion support for PostgreSQL runs only through Switch, its experimental LLM-based transpiler, so every converted object needs engineering review, and this inventory is the main input for effort estimates.

Target Design in Unity Catalog

Target design decides where every Postgres object will live before any data moves:

  • Databases and schemas: each ingestion pipeline writes to a destination catalog and schema in Unity Catalog, with bronze, silver and gold layers organized inside
  • Roles and grants: Unity Catalog privileges govern access to the migrated tables in one place across workspaces
  • Row-level security: Unity Catalog row filters and column masks restrict access to specific rows and columns
  • Lakebase databases: registered in Unity Catalog, so application data sits beside analytics data under the same governance

Naming needs a decision at this stage too. Postgres allows mixed-case quoted identifiers, while Unity Catalog stores names in lowercase, so a table such as “CustomerOrders” needs an agreed target name before pipelines and reports start referencing it.

Data Movement and Code Conversion

Data and code move on separate tracks, so neither blocks the other.

On the data track, Lakeflow Connect takes an initial snapshot of each table, then streams every insert, update and delete from the replication slot, so the Postgres source keeps serving users throughout. Very large historical tables can load from bulk exports instead.

On the code track, engineers convert the logic that depends on that data: an order summary function written in PL/pgSQL becomes a Databricks SQL procedure, and the nightly pg_cron refresh becomes a Lakeflow Jobs task.

Lakebridge Switch can draft PostgreSQL conversions, and each converted object is reviewed and tested against the Postgres output before it enters a pipeline.

Validation and Parallel Run

CheckWhat It Proves
Schema and type comparisonEvery column landed with the intended type
Row counts per table and dateNo rows were lost or duplicated
Aggregates on key numeric columnsSums, minimums and maximums match
Report and query comparisonBusiness outputs match Postgres results

Both systems run side by side until owners sign off on each report or application.

Lakehouse Federation makes the comparison easier, since the same query can run against the Postgres source and the Delta target from one Databricks SQL editor without exports.

Databricks recommends running pipelines in parallel for a specific period and reviewing the comparison results.

Cutover and PostgreSQL Decommissioning

Cutover follows a fixed order, one wave at a time:

  1. Repoint BI tools, applications and downstream pipelines to the Databricks tables
  2. Confirm that final row counts and aggregates match the source
  3. Stop and delete the Lakeflow Connect pipeline
  4. Drop its replication slot and publication, since deleting a pipeline does not remove the slot and WAL would keep accumulating
  5. Retire read replicas, ETL servers and backup policies that served only this database

How Databricks Connects to PostgreSQL for Migration

Databricks reaches PostgreSQL in four ways, each suited to a different migration stage: federation for querying in place, JDBC for batch reads, Lakeflow Connect for CDC and file exports for bulk history.

MethodBest ForKey Detail
Lakehouse FederationQuerying Postgres during the transitionPushes filters, aggregates and limits down to Postgres; join pushdown is in Public Preview
JDBC readsOne-time or small batch loadsSimple, but puts query load on the source
Lakeflow Connect PostgreSQL connectorOngoing change data capturePublic Preview, Postgres 13 and later, up to 250 tables per pipeline recommended
CSV or Parquet export to cloud storageLarge historical tablesLoaded with Auto Loader, no change capture

Federation can serve as a first step. It lets analysts query Postgres tables from Databricks SQL before any data moves.

Federation has limits worth knowing. Window functions are not pushed down, so heavy analytical queries still pull large volumes across the network and add load to the source. It suits discovery and light reporting.

The Lakeflow Connect connector then takes over for tables that need continuous updates. It runs as a pair: an ingestion gateway on classic compute, kept in continuous mode so WAL does not build up, and an ingestion pipeline on serverless compute that writes Delta tables governed by Unity Catalog.

The connector currently supports username and password authentication only, and each database being ingested needs its own replication slot and publication, which security teams should know before approving it.

How to Configure PostgreSQL for Ingestion Into Databricks

Configuring PostgreSQL for Lakeflow Connect means enabling logical replication, creating a dedicated replication user, setting replica identity, and creating publications and pgoutput replication slots.

Setup uses two sets of credentials. An admin or table owner prepares the database, while a dedicated replication user runs ingestion, and only that user’s credentials are stored in the Unity Catalog connection.

Enable Logical Replication and Create a Replication User

The database must run PostgreSQL 13 or later with wal_level set to logical, which requires a restart if it is not already set. Network access from the Databricks workspace comes next, through security groups, firewall rules or a VPN for on-premises servers.

The replication user, typically named databricks_replication, needs the REPLICATION attribute, CONNECT on the database, USAGE on each schema and SELECT on each table being ingested. Databricks recommends a separate replication user, so built-in PostgreSQL permissions can keep other databases and tables out of its reach.

Databricks connects to PostgreSQL over TLS and JDBC, and credentials stay in Unity Catalog, retrievable only by users with the right permissions.

Set Replica Identity for TOAST and Keyless Tables

Replica identity controls how much of each changed row PostgreSQL writes to the log:

Table StructureReplica Identity
Primary key, no large text or binary columnsDEFAULT
Primary key with large TOASTable columnsFULL
No primary keyFULL

TOAST is how Postgres stores large values such as long TEXT or BYTEA fields. With DEFAULT, an update that does not touch those columns can arrive without their values, so the connector needs FULL to rebuild complete rows.

Tables without a primary key carry one more risk: identical duplicate rows collapse into one in the target, so they need a key or a deliberate decision before ingestion.

Create Publications and pgoutput Replication Slots

Order matters here. Each database needs one publication, created by the table owner or a superuser, listing the tables to replicate. FOR ALL TABLES is simpler but requires superuser rights and sends more traffic than needed.

The replication slot comes after the publication, created by the replication user with the pgoutput plugin, the only plugin Databricks supports. Databases replicated together each need their own publication and slot, and max_replication_slots and max_wal_senders must be set high enough to cover them.

Keeping the publication to the tables that are needed reduces unnecessary network traffic.

Partitioned tables need more care, since the connector treats each partition as a separate table, and adding or removing partitions requires a full refresh of the parent table.

Managed PostgreSQL Settings for RDS, Azure and Cloud SQL

PlatformRequired Setting
Amazon RDS and Aurorards.logical_replication = 1 in the parameter group, plus the rds_replication role for the replication user
Azure Database for PostgreSQLLogical replication enabled in server parameters; Flexible Server supports logical replication
Google Cloud SQLThe cloudsql.logical_decoding flag enabled

Setting wal_level to logical typically requires a database restart.

Self-managed servers on virtual machines or on-premises follow the general steps, with connectivity through ExpressRoute, AWS Direct Connect or a VPN. Cloud SQL users running pglogical also set cloudsql.enable_pglogical to on.

Monitor Replication Slots and WAL Growth

A replication slot holds write-ahead log on the source until Databricks confirms it has read the changes. If the gateway stops, or a test pipeline is deleted, the slot keeps holding WAL, and the source disk fills.

Three rules help. First, max_slot_wal_keep_size should have a finite value, since the default of -1 allows unlimited retention. Some managed providers do not allow changing it and rely on built-in slot monitoring, so review the platform behavior before setting alerts.

Second, the slot of every deleted pipeline is dropped by hand, because Databricks does not remove it. Third, failover plans account for the connector reading only from the primary: when a primary is replaced, the slot is lost and every table in the pipeline needs a full refresh.

Migrating Analytical PostgreSQL Workloads to the Databricks Lakehouse

Analytical PostgreSQL workloads move to Delta Lake, where data types need deliberate mapping and PL/pgSQL logic is rebuilt as Databricks SQL, Python and Lakeflow pipelines.

PostgreSQL to Delta Lake Data Type Mapping

Lakeflow Connect converts most types automatically, but several land as strings and need a decision in the silver layer:

PostgreSQL TypeArrives in Databricks AsSilver Layer Action
NUMERIC(p,s)DECIMAL(p,s)Precision above 38 arrives as a string
TIMESTAMP WITH TIME ZONETIMESTAMPStored in UTC; values above the supported maximum become null
TIMESTAMP without time zoneSTRINGArrives as a string in its original format, with Inf and -Inf preserved; parse it with SQL functions
JSON, JSONBSTRINGParse into structs or the VARIANT type
ARRAYSTRINGParse into arrays where queries need elements
UUIDBINARYArrives as binary, so convert it where a string key is needed
MONEYSTRINGArrives as a string, so parse it before using it as a number
INTERVAL, TIMESTRINGParse with SQL functions as needed
Extension and custom typesSTRINGReview case by case

Two naming details also surface early. Tables whose names differ only in case, such as Orders and orders, cannot share a pipeline, and two tables with the same name in different schemas cannot either, so large databases often need several gateway and pipeline pairs.

Very large single values also need checking, since any single value above about 10 MB is ingested as empty.

Converting PL/pgSQL Functions and pg_cron Schedules

Databricks SQL now supports stored procedures and SQL scripting with variables, loops and error handling, so procedural logic can be rebuilt on the platform. Row-by-row loops can be rewritten as set-based SQL statements that run in parallel.

Each trigger’s logic is reviewed object by object, since converted code needs engineering review. Materialized views refreshed by cron move to Databricks materialized views, and pg_cron schedules become Lakeflow Jobs with dependencies, retries and alerts.

Dynamic SQL is the other area to inventory. PL/pgSQL EXECUTE statements that build queries from strings map to EXECUTE IMMEDIATE in Databricks SQL, and set-returning functions become SQL table functions in Unity Catalog. Functions that depend on extensions, such as PostGIS geometry logic, need case-by-case redesign.

Migrating Operational PostgreSQL Workloads to Lakebase

Operational PostgreSQL databases move to Lakebase through pg_dump for one-time copies or logical replication that keeps the target current until cutover, with extension and permission checks first.

Lakebase runs standard Postgres, so application SQL carries over. The work is in the platform differences:

  • Extensions: compare each installed extension against the Lakebase supported list before planning, since a missing one can block an application
  • Superuser access: not available; the databricks_superuser role replaces it, and functions that need file system access will not run
  • Configuration: only session, database and role level parameters can be set, and tablespaces are not supported
  • Scale-to-zero: new Lakebase projects scale to zero when idle, which closes connections and drops session state such as temporary tables, prepared statements and advisory locks, so applications that rely on these must turn it off

Logical replication into Lakebase follows a strict sequence. Logical replication copies data but not schema, so target tables are created first and must be empty. The subscription connects to the source over a public endpoint, since Private Link is not supported for that connection, then copies existing rows and streams changes until every table reports ready.

At cutover, writes stop on the source and the team confirms Lakebase has caught up. Sequences need attention here, because copying rows without advancing sequences can cause duplicate-key errors after promotion, and sequence synchronization is a PostgreSQL 19 feature. The application then switches its connection string, and the subscription is dropped to release the source slot.

Databases that can accept downtime take the simpler route. A custom-format pg_dump of the source is restored into Lakebase with pg_restore, followed by a row count comparison per table.

Databricks recommends logical replication, not pg_dump, for migrations that keep the target current until cutover.

Plan Your PostgreSQL to Databricks Migration With LatentView

Our Databricks Center of Excellence brings 400 data engineers, 150+ of them certified. For a wealth management platform, we processed 350 GB of data daily on Databricks and optimized its code by 42%.

PostgreSQL migrations split into analytics on Delta Lake and applications on Lakebase, each with its own data movement and conversion work. As a Databricks Elite C&SI partner, we use MigrateMate, our cloud migration solution, to assess, convert and validate workloads in waves. Talk to our Data Engineering Expert about scoping your first migration wave.

Frequently Asked Questions About PostgreSQL to Databricks Migration

1. Can Databricks Connect to PostgreSQL?

Yes. Databricks connects to PostgreSQL through Lakehouse Federation, JDBC and the Lakeflow Connect PostgreSQL connector for change data capture.

2. What Is Lakebase?

Lakebase is a fully managed Postgres database built into Databricks, with autoscaling, branching and synced tables that connect it to the lakehouse.

3. Does Lakebridge Support PostgreSQL?

Lakebridge supports PostgreSQL conversion through its experimental Switch transpiler, so every converted object needs engineering review.

4. How Does JSONB Arrive in Databricks?

Lakeflow Connect ingests JSON and JSONB as strings. Silver layer pipelines then parse the JSON into structs or the VARIANT type.

5. Which PostgreSQL Versions Does Lakeflow Connect Support?

The Lakeflow Connect PostgreSQL connector supports PostgreSQL 13 and later, with logical replication and the pgoutput plugin.

LatentView Analytics has been helping enterprises make data-driven decisions for nearly 20 years. The company brings deep expertise in data engineering, business analytics, GenAI, and predictive modeling to 50+ Fortune 500 clients across tech, retail, financial services, and CPG. A publicly traded company serving the US, India, Canada, Europe, and Singapore, LatentView is recognized in Forrester's Customer Analytics Service Providers Landscape.

CATEGORY

LatentView Analytics has been helping enterprises make data-driven decisions for nearly 20 years. The company brings deep expertise in data engineering, business analytics, GenAI, and predictive modeling to 50+ Fortune 500 clients across tech, retail, financial services, and CPG. A publicly traded company serving the US, India, Canada, Europe, and Singapore, LatentView is recognized in Forrester's Customer Analytics Service Providers Landscape.

Take to the Next Step

"*" indicates required fields

consent*

Related Blogs

This guide helps data and technology leaders plan an SAP to Databricks migration, from choosing the…

This guide helps data and technology leaders plan an Informatica to Databricks migration, from choosing a…

This guide helps data and technology leaders plan an Oracle to Databricks migration, from understanding the…

Scroll to Top