---
title: "ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 2"
description: "ClickHouse dictionaries backed by a PostgreSQL source can replace joins against Postgres-resident mapping tables, keeping the data in memory and refreshing it via LIFETIME and an invalidate_query."
url: "https://swe.quest/articles/clickhouse-and-postgresql-a-match-made-in-data-heaven-part-2-67e202f8b29633ab"
canonical: "https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2"
source: "ClickHouse"
published: "2023-01-26"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["analytics","postgres","data-pipelines","sql","performance"]
---

# ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 2

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-01-26, 8 min read, How-to. Original: [https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2)

## Summary

ClickHouse dictionaries backed by a PostgreSQL source can replace joins against Postgres-resident mapping tables, keeping the data in memory and refreshing it via LIFETIME and an invalidate\_query. On the UK house price dataset, a regional price-change query took 48.5s in Postgres, 4.1s in ClickHouse when joining through the PostgreSQL table engine, and 0.44s using dictGet against a complex\_key\_hashed dictionary. The PostgreSQL table engine also supports "reverse ETL": an INSERT ... SELECT can push aggregated monthly price statistics computed in ClickHouse back into a Postgres summary table for a user-facing application to query.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- SQL joins and aggregation ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

ClickHouse, PostgreSQL, ClickHouse dictionaries, PostgreSQL table engine, Supabase, reverse ETL, ClickHouse Cloud

## Related posts

- [ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 1](https://swe.quest/articles/clickhouse-and-postgresql-a-match-made-in-data-heaven-part-1-7c7668b9b4913b70.md): ClickHouse · 2022-12-20 · Medium · 18 min read · Analytics & OLAP, PostgreSQL, Query engines, Performance engineering, SQL
  ClickHouse can query PostgreSQL data in place through the postgresql table function and the PostgreSQL table engine.
- [Longbridge Technology simplifies their architecture and achieves 10x performance boost with ClickHouse](https://swe.quest/articles/longbridge-technology-simplifies-their-architecture-and-achieves-10x-e3a982c02b6e4b33.md): ClickHouse · 2025-03-17 · Medium · 8 min read · Analytics & OLAP, Databases, PostgreSQL, Payments & fintech
  Longbridge, a Singapore online brokerage, replaced a fragmented market-data stack of PostgreSQL (historical), Redis (real-time) and DynamoDB (high-write) with ClickHouse after evaluating it against TimescaleDB and TDengine for write throughput, Decimal support, time functions and aggregations.
- [PostgreSQL + ClickHouse as the Open Source unified data stack](https://swe.quest/articles/postgresql-clickhouse-as-the-open-source-unified-data-stack-2760f19ba52907df.md): ClickHouse · 2026-01-27 · Easy · 5 min read · PostgreSQL, Analytics & OLAP, Event-driven architecture, Replication
  An open source stack pairs PostgreSQL as the transactional system of record with ClickHouse for analytics, connected by PeerDB for change data capture and the pg\_clickhouse extension, which transparently offloads analytical queries from Postgres to ClickHouse.
- [Introducing pg\_clickhouse: A Postgres extension for querying ClickHouse](https://swe.quest/articles/introducing-pg-clickhouse-a-postgres-extension-for-querying-clickhouse-98de49fb9ae8bb75.md): ClickHouse · 2025-12-10 · Medium · 11 min read · PostgreSQL, Query engines, Analytics & OLAP, SQL
  pg\_clickhouse v0.1.0 is an Apache 2-licensed PostgreSQL foreign data wrapper, derived from clickhouse\_fdw, that runs analytics queries on ClickHouse from Postgres so existing queries can work unmodified by changing search\_path.
- [A universal interface: How QuintoAndar made ClickHouse plug-and-play with managed Postgres](https://swe.quest/articles/a-universal-interface-how-quintoandar-made-clickhouse-plug-and-play-with-ec413a5dd96fc04f.md): ClickHouse · 2026-08-27 · Easy · 6 min read · Analytics & OLAP, PostgreSQL, Data pipelines, System design
  QuintoAndar's customer data platform replaced a Lambda architecture (a Postgres hot layer plus Kafka Connect into a Delta landing zone processed by 24/7 Databricks jobs with costly MERGE INTO deduplication) by having its event gateway write about 900 million monthly events directly into ClickHouse Cloud, which also serves roughly 300 million API requests a month with sub-second reads.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
