---
title: "Postgres FDW: Pushdown is a negotiation"
description: "Postgres Foreign Data Wrapper extensions allow PostgreSQL to query external datastores like ClickHouse by delegating execution to remote engines. Engineering pg_clickhouse centers on pushdown decisions that determine whether SQL expressions run remotely or stream raw data back across the wire. Because pushdown depends on planner callbacks, deparser translations, and ClickHouse semantic compatibility, a single untranslated clause can block upper-level query pushdown entirely. Resolving pushdown barriers enables complex analytic queries to return hundreds of rows in milliseconds rather than pulling tens of millions of rows for local processing. Ultimately, pushdown development requires an iterative negotiation across differing SQL grammars, occasionally requiring the revocation of translations that fail to maintain strict equivalence."
---

# Postgres FDW: Pushdown is a negotiation

[Clickhouse](https://yomu.fyi/company/clickhouse) · Kaushik Iska, David Wheeler, Philip Dubé · May 14, 2026

**Type:** Explainer

## Summary

Postgres Foreign Data Wrapper extensions allow PostgreSQL to query external datastores like ClickHouse by delegating execution to remote engines. Engineering pg\_clickhouse centers on pushdown decisions that determine whether SQL expressions run remotely or stream raw data back across the wire. Because pushdown depends on planner callbacks, deparser translations, and ClickHouse semantic compatibility, a single untranslated clause can block upper-level query pushdown entirely. Resolving pushdown barriers enables complex analytic queries to return hundreds of rows in milliseconds rather than pulling tens of millions of rows for local processing. Ultimately, pushdown development requires an iterative negotiation across differing SQL grammars, occasionally requiring the revocation of translations that fail to maintain strict equivalence.

## Context

PostgreSQL Foreign Data Wrappers (FDWs) like pg\_clickhouse query remote systems like ClickHouse, but transferring raw data across the network for local aggregation is slow. Engineering efficient FDW queries depends on determining which SQL clauses can be safely pushed down to the remote database without altering query semantics.

## Approach / What changed

pg\_clickhouse registers planning callbacks such as GetForeignPaths, GetForeignJoinPaths, and GetForeignUpperPaths with the Postgres planner. Its SQL deparser incrementally maps Postgres expressions—such as JSON access, window functions, and filtered aggregates—into ClickHouse SQL, prioritizing semantic correctness and revoking pushdowns when exact behavioral parity cannot be guaranteed.

## Takeaways

- Pushdown is granular and all-or-nothing at the upper-relation level; a single unsupported sub-expression or aggregate can block an entire grouped query from running remotely.
- Foreign Data Wrappers register specific planning callbacks in Postgres, including GetForeignPaths and GetForeignUpperPaths, to offer foreign execution paths before deparsing SQL.
- Pushdowns must be revoked if SQL dialect semantics diverge, as seen when pg\_clickhouse removed array function pushdowns to prevent returning incorrect results.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Performance](https://yomu.fyi/topic/performance), [Postgres](https://yomu.fyi/topic/postgres)

- Source: [Clickhouse](https://clickhouse.com/blog/postgres-fdw-pushdown-negotiation)
- Source URL: https://clickhouse.com/blog/postgres-fdw-pushdown-negotiation
- Ingested by Yomu: 2026-08-28T01:25:51.810Z

[Read original post](https://clickhouse.com/blog/postgres-fdw-pushdown-negotiation)
