Writing a Foreign Data Wrapper
summary
Explains how to implement a PostgreSQL foreign data wrapper written in C (with an optional multicorn Python wrapper), what required FDW callbacks are (get_rel_size, get_foreign_paths, begin_foreign_scan, iterate_foreign_scan, rescan, end_foreign_scan), and that the planner receives internal paths not raw SQL. Shows handling of Datum types, Postgres memory contexts, validator/import_schema hooks, and cost hints (startup can be ~10s for remote connections). Demonstrates a working FDW: an “infinite” random-float table that performs pretty fast.
AI-written summary · about
chapters (20)
- 0:00Intro
- 0:11Let's talk foreign data wrappers!
- 1:03OK, fine, what's a foreign table?
- 2:38A Foreign Data Wrapper!
- 3:20What does an FDW do?
- 8:23Error Handling.
- 9:27Datum.
- 11:03Types.
- 14:15Execution Order
- 14:48GetForeignRelSize
- 19:08GetForeignPaths
- 20:23Estimating Costs.
- 25:19BeginForeignScan
- 26:58The Steps.
- 28:16Memory Management.
- 32:35ImportForeignSchema
- 34:51Options.
- 37:27Multicorn.
- 38:12Have fun!
- 39:11A last note of caution.
related talks
50mBeyond Foreign Data Wrappers: building a data warehouse from heterogeneous external data sources
52mSharding PostgreSQL using Foreign Data Wrappers
51mUsing Postgres FDW with a sharded PostgreSQL Database
54mFederating Queries Using postgres_fdw
34mJoining Heterogeneous Databases is a reality, not a Myth
25mRuby and PostgreSQL, a love story
47mpg_shardman: Sharding in PostgreSQL
27mMigrating from MSSQL to PostgreSQL
