Adding Async Streaming to Postgres Foreign Data Wrappers
Supabase Wrappers' ClickHouse foreign data wrapper now streams results asynchronously instead of fetching full result sets or fixed batches while blocking the Postgres backend. A background Rust async task pulls rows from ClickHouse as they arrive and pushes them into a bounded channel (default 1024 rows). The Postgres backend reads from that channel synchronously, one row at a time, so memory stays bounded and the first rows come back sooner, even on billion-row scans. The pattern is reusable within Wrappers and will be extended to BigQuery, Snowflake, S3, Stripe and other connectors.
Related posts
- Supabase Wrappers v0.2: Query Pushdown & Remote Subqueries
Supabase mediumAdeptSupabase Wrappers v0.2, a Rust-based Postgres foreign data wrapper framework for querying third-party sources with SQL, adds query pushdown, remote subqueries and per-FDW usage statistics. Pushdown is implemented inside each wrapper, so a filter on a Stripe customer id becomes a single API call and ClickHouse queries can push down ORDER BY and LIMIT. Remote subqueries map a static query, or a parameterized ClickHouse/BigQuery view whose parameters are exposed as columns, onto a foreign table. A new wrappers_fdw_stats table records rows and bytes transferred in each direction for spotting bottlenecks, and the release also adds Airtable and S3 wrappers.
- Supabase Wrappers, a Postgres FDW framework written in Rust
Supabase mediumAdeptSupabase Wrappers is an alpha Rust framework, built on pgx, for writing Postgres Foreign Data Wrappers that expose external systems such as Stripe and Firebase as queryable foreign tables. A worked example connects a Stripe account, maps products to a foreign table and queries it with SQL or the Supabase JS client. Wrappers also support a "QETL" (query, extract, transform, load) pattern: query warehouses like Snowflake on demand, join remote data with local tables, and materialize results with pg_cron. The framework adds async support for REST-API-backed FDWs and early push-down support, with ClickHouse, BigQuery and Airtable wrappers in development.
- What's New in pg_clickhouse - JSONB Support, SQL value functions, Streaming, and more
ClickHouse mediumAdept
pg_clickhouse, the Postgres foreign data wrapper for querying ClickHouse, now pushes down far more operations to ClickHouse. JSONB accessors (->, ->>, jsonb_extract_path) are translated to ClickHouse sub-column syntax. CURRENT_DATE, CURRENT_TIMESTAMP and clock_timestamp() are translated to ClickHouse now()/now64()/nowInBlock64 calls that use the Postgres session time zone and timestamp precision. Array functions now map to their ClickHouse equivalents. Streaming of HTTP driver results in roughly 50MB batches kept container memory under about 100MiB during a full NYC taxi table scan, versus about 600MiB without it.
- Sync Stripe Data to Your Supabase Database in One Click
Supabase mediumAdeptSupabase now offers a one-click Stripe Sync Engine integration that copies Stripe customers, subscriptions, invoices and payments into real Postgres tables, kept current via webhooks plus scheduled backfills run through pgmq-based Supabase Queues and Edge Functions with retries. Unlike the existing Stripe Foreign Data Wrapper, which translates each query into Stripe API calls and slows down or hits rate limits on joins and aggregations, the sync engine lets queries run against local indexed data. Example SQL shows finding unconverted signups, computing MRR by plan, and spotting inactive paying accounts. Stripe contributed JSONB storage with generated columns, cursor-based incremental sync, Connect multi-account support and a CLI to the open-source engine.
- Longbridge Technology simplifies their architecture and achieves 10x performance boost with ClickHouse
ClickHouse mediumAdept
Longbridge, a Singapore online brokerage, replaced a fragmented market-data stack of PostgreSQL (historical), Redis (real-time) and DynamoDB (high-write) with ClickHouse after evaluating it against TimescaleDB and TDengine for write throughput, Decimal support, time functions and aggregations. Historical data was migrated via ClickHouse external tables over OSS and Alibaba Cloud DTS, which merged 128 PostgreSQL sub-tables into one table and converted varchar fields to Decimal; Redis was kept for real-time data with ticker-level writes moved to ClickHouse. Reported results include about 5x compression (500GB down to 100GB), 10x faster single-table writes than PostgreSQL, and built-in aggregation and window functions replacing scheduled statistics jobs.