Threads (@aiposthub)
ai-engineeringdev-tools
Original source

PGX — 用 Rust 打造的輕量 Postgres,專為 AI Agent 設計

Summary

PGX 是一個用 Rust 寫的 PostgreSQL 相容資料庫引擎,專為 AI Agent 的短命資料庫場景設計。

核心賣點

  • 1 個 PGX runtime 可跑數千個隔離資料庫(非 1 DB = 1 server 模式)
  • 1,000 個 idle 資料庫僅需 128-155 MB 記憶體(每個 ~70-128 KB)
  • 資料庫建立時間 ~6.2ms(warm mint, p50)
  • 支援 copy-on-write(ZFS):10GB template 的 branch 只需 ~14MB 額外空間,~674ms 就緒
  • 通過 219/231 PostgreSQL regression tests(byte-exact match against PG 18.6)

設計理念

  • 資料庫應該像分配 object 一樣便宜,而非像 provision server 一樣昂貴
  • 生命週期:sealed template → mint DB (ms) → agent 使用 (min/hr) → discard
  • 講 Postgres wire protocol + SQL dialect,Rails/Django/Prisma/SQLAlchemy 等直接相容

使用場景

  • AI Agent sandbox(coding agent 的 create → migrate → test → discard 循環)
  • CI / per-PR databases
  • Test / preview environments

快速開始

npx pgxdb@latest
# 一行指令:安裝 PGX、啟動 DB、輸出 connection URL
# 不需要 Docker,支援 Mac & Linux

專案資訊

  • 語言:Rust
  • 授權:AGPL-3.0
  • 版本:v0.1.0(2026-10-08 建立)
  • 官網:https://pgx.dev
  • 注意:目前標記為 “disposable databases, not production data”