Building a Foreign Data Wrapper
summary
Postgres FDW API exists since 9.3 (2011) and extensions are written in C; pg_clickhouse evolves from postgres_fdw and clickhouse_fdw and raises supported expression node types from 21 to 35 (postgres_fdw ~29). Planning uses callbacks like get_foreign_relation_size, get_foreign_paths, get_foreign_join_paths, get_foreign_upper_paths, and get_foreign_plan to tag remote vs local clauses, set costs, and build remote SQL. Implementation adds is_foreign_expression and deparse_expression, sets a 50 MB fetch size, and specifically maps SQL value functions (current_date/time), unsigned ints and RE2 regex for pushdown.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker background
- 3:31What is a foreign data wrapper
- 7:20Pushdown optimization basics
- 15:29Foreign join paths callback
- 20:49Foreign upper paths callback
- 27:08Planning and pushdown negotiation
- 35:35Starting simple and iterating
- 37:02Adding SQL value function support
- 42:16Four categories of pushdown mapping
- 45:06Q&A on pushdown trade-offs
