We demonstrate how to use PostgreSQL’s planner hook to open a side entrance through which we can pass plan trees for immediate execution. Since this reaches deep into PostgreSQL, we implement plan detail inference and decoration to ensure that externally crafted trees perfectly mimic regular plans. Plan trees may then
- be generated by external code generators that want to use PostgreSQL as a reliable and efficient back-end for new (maybe even non-relational) languages, or
- stem from experimental rewrites of SQL plans that PostgreSQL itself does not implement (yet).
The demonstration provides a live account of what becomes possible once we let PostgreSQL hatch foreign plan eggs.