GreptimeDB, an open-source time-series database built in Rust, now supports the full PostgreSQL wire protocol. The team used two reusable Rust crates: pgwire for handling the protocol and DataFusion for query execution. This “top-down” compatibility lets developers connect standard Postgres clients like psql, JDBC drivers, or pgAdmin directly to GreptimeDB without custom code.
Why build this? GreptimeDB targets observability and IoT workloads, where time-series data dominates. Full Postgres compatibility unlocks an ecosystem worth billions in tools and integrations. Existing Postgres drivers number in the dozens across languages—Python’s psycopg2, Go’s pgx, Node’s pg—and management tools like pg_dump or Tableau plug right in. No more vendor-specific clients.
The Postgres Protocol Dissected
The core Postgres protocol runs over TCP as version 3.0, stable since 2004. It breaks into five main flows:
- Startup: Negotiates connection, TLS, and authentication (MD5, SCRAM-SHA-256, etc.).
- Simple Query: Sends plain SQL text; server parses, executes, returns results.
- Extended Query: Prepares statements on the server, binds parameters, executes—key for prepared statements.
- Copy: Streams bulk data in/out, like COPY FROM STDIN.
- Cancel: Kills a running query mid-flight.
But wire-level support isn’t enough. GreptimeDB maps its SQL dialect to Postgres’, aligns 50+ data types (integers, timestamps, arrays), and implements pg_catalog—the metadata schema clients query for schema info, functions, and types. Skip this, and tools like DBeaver fail.
GreptimeDB skips logical replication and streaming replication protocols, focusing on query access. That’s pragmatic: replication adds complexity without core benefits for a time-series DB.
Implementation: pgwire + DataFusion
Pgwire, an Apache 2.0 crate, parses the frontend protocol—handling messages, authentication, and result formats. It’s battle-tested in projects like Materialize. DataFusion, from Apache Arrow, executes SQL via a vectorized engine optimized for columnar data. GreptimeDB wires them together: pgwire receives queries, DataFusion plans and runs them against GreptimeDB’s storage (object storage + WAL for time-series).
They open-sourced the glue code as libraries. Developers can fork this for custom DBs. Example integration:
use pgwire::PgServer;
use datafusion::prelude::*;
let server = PgServer::create()
.handler(|ctx, query| {
// Execute with DataFusion
let df = ctx.sql(query).await?;
df.collect().await
})
.listen("0.0.0.0:5432");
This reusability matters. Rust’s Postgres ecosystem splits: “bottom-up” via pgrx (PGXS for Rust extensions, used in ParadeDB for full-text search) embeds Rust into Postgres. “Top-down” like GreptimeDB emulates Postgres atop custom engines. Top-down wins for non-relational stores—time-series, graphs—avoiding Postgres’s MVCC overhead.
Why This Matters—and the Caveats
Postgres compatibility delivers proven reliability: a decade-plus protocol with TLS 1.3, GSSAPI auth, and streaming rows (up to 64KB chunks). It beats rolling your own—no reinventing auth or escaping hacks.
Implications hit hard in 2025’s Postgres surge. Acquisitions like Neon’s serverless Postgres (by Databricks?) and Crunchy Data amplify the hype. GreptimeDB sidesteps by being “Postgres-compatible, not Postgres.” Users get psql for ad-hoc queries on metrics data, ETL tools like Airbyte for ingestion, BI like Metabase without adapters.
Skeptical take: Full compatibility claims often falter. GreptimeDB supports core SQL but likely skips Postgres extensions (PostGIS, pg_trgm), advanced features (window functions on non-time-series?), or vacuuming semantics. Performance? DataFusion shines on analytics (benchmarks show 10x over Postgres on TPC-H), but wire protocol adds latency vs native APIs. Test with pgbench: expect 50-80% of native Postgres TPS on OLTP.
Still, for time-series at scale—think Prometheus replacement—this lowers barriers. Open libraries accelerate Rust DBs like RisingWave or InfluxDB forks. Developers save months; ecosystems compound. If you’re building or migrating, benchmark it: clone GreptimeDB, spin up Docker, connect psql. Real compatibility shows in production queries, not blog posts.



