Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 24, 2026·3 min de lecture

pgrust — PostgreSQL Rewritten in Rust

A from-scratch reimplementation of PostgreSQL in Rust that passes the full PostgreSQL regression test suite, exploring memory-safe systems programming for database engines while maintaining wire-protocol compatibility.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
pgrust
Commande avec revue préalable
npx -y tokrepo@latest install 224d0122-8738-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

Introduction

pgrust is an experimental reimplementation of the PostgreSQL database in Rust. It passes 100% of the standard PostgreSQL regression tests, demonstrating that a memory-safe language can faithfully reproduce the behavior of one of the most complex open-source C codebases. The project serves as both a research artifact and a foundation for exploring Rust-native database innovations.

What pgrust Does

  • Implements the PostgreSQL wire protocol so standard clients like psql connect without modification
  • Passes the full PostgreSQL regression test suite covering SQL parsing, planning, and execution
  • Provides a storage engine compatible with PostgreSQL's on-disk format
  • Supports core SQL features including joins, subqueries, CTEs, window functions, and transactions
  • Eliminates entire classes of memory safety bugs present in the original C implementation

Architecture Overview

The codebase mirrors PostgreSQL's architecture — a postmaster process that forks (spawns) per-connection backends, each running a parser, planner, and executor. The parser produces an AST from SQL text, the planner generates query plans using cost-based optimization, and the executor walks the plan tree to produce results. The key difference is that all of this is written in safe Rust with minimal unsafe blocks, relying on Rust's ownership model for memory management instead of PostgreSQL's custom memory contexts.

Self-Hosting & Configuration

  • Build from source with a recent Rust toolchain (1.75+) using cargo build --release
  • Initialize a data directory with the built-in initdb equivalent
  • Start the server pointing to the data directory and configure the listen port
  • Connect using any PostgreSQL client driver (libpq, JDBC, psycopg2)
  • Configuration parameters mirror PostgreSQL's postgresql.conf where implemented

Key Features

  • Full PostgreSQL regression test compatibility proving behavioral fidelity
  • Memory safety through Rust's ownership and borrowing system
  • Wire-protocol compatibility with existing PostgreSQL client libraries
  • Single-binary deployment without external C library dependencies
  • AI-assisted development approach documented in the repository

Comparison with Similar Tools

  • PostgreSQL — the original C implementation; pgrust is a Rust reimplementation aiming for compatibility
  • CockroachDB — distributed SQL in Go; pgrust is a single-node PostgreSQL clone
  • Neon — serverless Postgres with storage separation; pgrust is a complete engine rewrite
  • DuckDB — analytical database; pgrust targets OLTP workloads like PostgreSQL
  • TiDB — MySQL-compatible distributed DB; pgrust is PostgreSQL-compatible and single-node

FAQ

Q: Is pgrust production-ready? A: Not yet. It is an experimental project that demonstrates feasibility. Many PostgreSQL extensions and edge-case behaviors are still being implemented.

Q: Does it support PostgreSQL extensions? A: Not currently. The extension loading mechanism from PostgreSQL has not been ported, so extensions like PostGIS or pg_vector are not available.

Q: How does performance compare to PostgreSQL? A: Performance benchmarking is ongoing. The goal is compatibility first, with performance optimization as a secondary objective.

Q: Can I migrate an existing PostgreSQL database to pgrust? A: In theory, the on-disk format compatibility allows this, but it is not recommended for production data given the project's experimental status.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires