Skip to content

feat: Postgres sidecar with postgres_fdw extension for some cross-shard queries#738

Open
levkk wants to merge 1 commit intomainfrom
levkk-fdw-fallback
Open

feat: Postgres sidecar with postgres_fdw extension for some cross-shard queries#738
levkk wants to merge 1 commit 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), allow to fallback to using the postgres_fdw Postgres extension with foreign partitioned tables.

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.

When a query comes in that requests to use the fdw backend manually, pgdog will 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 high 90%s Postgres compatibility in a sharded world.

@levkk levkk force-pushed the levkk-fdw-fallback branch 3 times, most recently 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
@levkk levkk force-pushed the levkk-fdw-fallback branch from d5e4fb9 to 89c2d53 Compare February 18, 2026 01:31
@levkk levkk changed the title postgres_fdw fallback feat: Postgres sidecar with postgres_fdw extension for some cross-shard queries Feb 18, 2026
postgres

intersting

save

save

save

bins

failing test

save

save

save

save

recreate

save

save

reconfigure after each reload

save

save

fix tests

tests

disable

now we"re getting somewhere

fix tests

window functions

run as postgres

fix: handle auth passthrough

fix: more passthrough auth

Make fdw backend explicit only

revert

save
@levkk levkk force-pushed the levkk-fdw-fallback branch from 53602fe to 144b4b9 Compare February 18, 2026 18:15
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

Comments