Pgrust: Rust-Based PostgreSQL Clone Passes Tests

The project pgrust has been published with an implementation of the PostgreSQL DBMS, rewritten in the Rust language using the c2rust translator and an AI assistant. It is stated that the project is not yet ready for use in production projects, but it already successfully passes all PostgreSQL regression tests, is compatible with the PostgreSQL 18.3 data storage format and can use the data directory from PostgreSQL 18.3. The project code is distributed under the AGPLv3 license, in contrast to the original PostgreSQL, which is distributed under a permissive license PostgreSQL, close to the BSD and MIT licenses. An online demonstration of capabilities based on assembly in WebAssembly is available, as well as a Docker image for quick launch.

The development goal is to achieve full compatibility with PostgreSQL 18.3, as well as conduct experiments to change the internal structure and create a version of PostgreSQL free from architectural restrictions that cannot be eliminated for historical reasons. The project successfully passes a set of more than 46 thousand PostgreSQL regression tests, but so far
is incompatible with PostgreSQL extensions, does not provide desired performance optimizations, and does not fully implement the procedural languages PL/Python, PL/Perl, and PL/Tcl.

Future plans:

  • Transition to a multi-threaded internal architecture.
  • Implement pooling connections.
  • Optimization for workflows that actively use JSON.
  • The ability to create copies and branches of database elements in Copy-on-Write mode without copying data.
  • Experiments with an architecture that does not require a VACUUM operation.
  • A system of SQL query restrictions that allows you to block unnecessary resource consumption when executing low-quality queries.
  • Switch protection optimizer for less efficient query execution plans.

According to words of the project author, work is currently underway on the next version of pgrust, which instead of a worker process pool implements a multi-threaded connection processing model, and also includes additional optimizations such as batch processing of rows in tables and pre-loading of data. When tested with the percona-tpcc toolkit, when processing transactions, the new version of pgrust turned out to be 50% faster than standard PostgreSQL, and 300 times faster when processing analytical queries.

When translating to Rust, a hybrid approach was used, in which the PostgreSQL code was first processed using a translator c2rust, which generates an unsafe representation of Rust, close in structure to the original C code. After processing in c2rust, about 1000 crate packages were created, which were simultaneously translated into idiomatic Rust using the Claude AI model and the Conductor toolkit for distributing tasks between simultaneously launched subagents.

/Reports, release notes, official announcements.