pgledger

Double-entry ledger implemented entirely in PostgreSQL functions and views

There is no application code: tables, SQL functions and views install into the same database as the app, so a ledger write commits atomically with the rest of its transaction. Any language posts transfers by calling functions and reads balances through views.

  • 13,557/sTransfers (M3 Air)
  • 9,306/sContended (10 accounts)
  • 774Bytes per transfer

Trade-offs

  • All logic in PostgreSQL, no application layer. It works across languages and commits atomically with the rest of the app, because every transfer is a SQL call in the same database.
  • Idempotency keys are optional. They make retries safe, at a measured 11,481 transfers/s against 13,557 and 951 bytes per transfer against 774.
  • Balance constraints are checked after each request, not at batch end. Limits hold at every step, but the same batch can pass in one order and be rejected in another.

Q&A4

Each call collects its account IDs, sorts them and takes FOR UPDATE locks in that order.

Reviews

Loading reviews

    More in Postgres

    See all 25 →
    • SupermetryCookie-free web and product analytics on one Go binary and PostgreSQL
    • arbiterPostgreSQL job queue for Haskell, with no broker and no leader
    • StreambedPostgres-to-Iceberg CDC engine with a built-in Postgres wire query server
    • MigrationPilotPostgreSQL migration linter that blocks unsafe DDL before merge
    • go-ledgerMulti-tenant double-entry payment ledger API in Go, built in public
    • pistachioDeclarative PostgreSQL schema management with a plan and apply workflow

    More in Fintech

    See all 21 →
    • FinTrackEvent-driven personal finance platform on Spring Boot, SQS and PostgreSQL
    • OffPayOffline UPI payments over *99# USSD, with no data connection
    • HisabDouble-entry ledger kept by texting a WhatsApp agent, in Urdu or English
    • PandaPayLensPayment error decoder and event timeline that runs in the browser
    • Edge ScannerLocal intraday stock scanner with setups built without code
    • Accountant24Personal finance agent that keeps an hledger ledger in plain text under git

    More in Ledgers

    See all 7 →
    • FinCore EngineSelf-hosted JVM core for a double-entry ledger, payments and compliance
    • franken_accountingEvidence-native double-entry accounting system of record in Rust