Skip to content

postgres_fdw fallback#738

Open
levkk wants to merge 27 commits intomainfrom
levkk-fdw-fallback
Open

postgres_fdw fallback#738
levkk wants to merge 27 commits intomainfrom
levkk-fdw-fallback

Conversation

@levkk
Copy link
Collaborator

@levkk levkk commented Feb 1, 2026

This is a big one.

For cross-shard SELECT queries that we don't support yet (some aggregate functions, CTEs / subqueries without the sharding key, OFFSET x, window functions), fallback to using the postgres_fdw extension.

We run an empty Postgres DB as a "sidecar" (subprocess of PgDog, really), and on boot, create all the foreign tables, partitioned by hash/list/range as configured in pgdog.toml. Partitioned tables are supported too, we use two-tier partitioning there, child tables use fdw.

We import custom types, schemas and extensions prior to this, so it should just work(tm).

When a query comes in, pgdog will check that any of the conditions are true, and if so, send the query to the fdw connection pool which will forward it to the shards via fdw, assembling the rows just like it would normally.

This is a superpower. If this works as intended, we will achieve 100% Postgres compatibility in a sharded world.

@levkk levkk force-pushed the levkk-fdw-fallback branch 2 times, most recently from 21b6a3e to 91d1b6f Compare February 4, 2026 23:43
@levkk levkk force-pushed the levkk-fdw-fallback branch from 91d1b6f to 73819ec Compare February 5, 2026 16:35
@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@levkk levkk marked this pull request as ready for review February 6, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant