apps/www/_blog/2024-10-30-supabase-clickhouse-partnership.mdx
We're seeing an emerging trend for AI customers: Postgres and ClickHouse is becoming the “default data stack”.
This makes sense - AI companies typically generate a lot of logs and analytical data, which is better suited for an OLAP database like ClickHouse.
<Quote img="justin-torre.png" caption="Justin Torre, CTO @ Helicone.ai">The combination of Supabase and ClickHouse together are perfect for Helicone.ai, providing the flexibility of Postgres with the analytical power of ClickHouse — an open-source stack we can trust and customize.
</Quote>The partnership between Supabase and ClickHouse aims to create a seamless experience, building on the already solid Postgres + ClickHouse foundation. Today, we're releasing new features to enhance this integration.
<Quote img="aaron-katz.jpg" caption="Aaron Katz, CEO @ ClickHouse Inc.">ClickHouse is very excited to partner with Supabase to make it easy for customers to use both technologies together. Through this partnership, we aim to make it even simpler for Postgres developers to use ClickHouse in conjunction and build real-time, data-driven applications at scale.
</Quote>Before diving into those changes, some context on how most customers use Supabase and ClickHouse together. While both are databases, they serve different use-cases:
Postgres is a row-oriented database, ClickHouse is column-oriented. The ClickHouse team have a great write up about the difference between the two formats.
To provide an interface between these, Supabase customers generally use:
We're making a number of changes to our platform based on the feedback we've had from customers.
Using the ClickHouse FDW, you can directly query your ClickHouse database from Postgres:
-- Connect Postgres to your ClickHouse database:
create foreign table user_analytics (
id bigint,
user_id bigint,
event text
)
server clickhouse_server
options ( table 'UserAnalytics' );
-- Query your ClickHouse instance from Postgres:
select * from user_analytics where user_id = 1;
This means you can query your ClickHouse data using the Postgres tooling that you're familiar with.
The Wrapper now has support for ClickHouse Parameterized Views. With this update, you can pass query parameters directly to ClickHouse, taking full advantage of its analytical engine::
create foreign table user_analytics (
id bigint,
user_id bigint,
_event text,
)
server clickhouse_server
options ( table '(select * from UserAnalytics(event=${_event}))' );
select * from user_analytics where _event='button_click';
Many of our customers use PeerDB to replicate data from Postgres to ClickHouse. This has occasionally presented challenges, particularly with Postgres's default 1GB WAL size, which, for large data volumes, can result in data loss if the WAL exceeds this size.
To resolve this, we've added 13 configurable Postgres parameters, enabling you to adjust replication settings through the CLI. For example, you can increase the default WAL size to 2GB:
supabase --experimental --project-ref xxxx-yyy \
postgres-config update --config max_slot_wal_keep_size=2GB
The new CLI config includes the following Postgres parameters:
Supabase now provides granular control over disk usage for your Postgres database:
This is driven directly by customers using tools like PeerDB. With adjustable WAL configuration, it's important that developers can manage the disk as well. For example, on the Pro Plan's 8GB disk, you can configure your project with options like:
Additionally, we're introducing High-performance Disks. We'll release more details about this later.
The ClickHouse team have also been busy. They've released a number of updates to their platform, including:
You can learn more about these features in the Supabase Partnership post they released today.
Improving the experience between Postgres and ClickHouse is the first phase of this partnership. We're already working on native platform integrations. If you're using (or plan to use) Supabase and ClickHouse together please reach out - we'd love more design partners to help shape the future of this integration.
If you simply want to try out the tools and updates we've described above, you can get started with all of them, free of charge: