Postgres FDW: Pushdown is a negotiation
Blog post from ClickHouse
Postgres extensions enhance functionality by allowing users to integrate features not originally included in Postgres, such as geospatial data handling with PostGIS and time-series data management with TimescaleDB. Foreign Data Wrapper (FDW) extensions enable Postgres to interact with external data sources, like ClickHouse, by creating foreign tables, allowing SQL queries across both systems. The process of determining what parts of a query are executed remotely, known as pushdown, is complex, involving the translation of SQL expressions between Postgres and ClickHouse to ensure accurate results. The development of pg_clickhouse, a ClickHouse FDW, involves iterative enhancements to expand pushdown capabilities for various SQL clauses such as window functions and JSON operations, significantly reducing data transfer volumes and execution times. The goal is to maximize remote execution while maintaining the integrity of query results, highlighting the intricate negotiation between different SQL grammars to optimize performance in a unified data stack.