pg_mentat
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_mentat | 1.5.7 | FEAT | Apache-2.0 | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2980 | pg_mentat | No | Yes | No | Yes | No | No | mentat |
The PIGSTY package omits optional mentatd and installs no user-facing binary; listed integrations are soft dependencies. Effective build uses pgrx 0.19.1, migrated from upstream 0.17.0.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.5.7 | 1817161514 | pg_mentat | - |
| RPM | PIGSTY | 1.5.7 | 1817161514 | pg_mentat_$v | - |
| DEB | PIGSTY | 1.5.7 | 1817161514 | postgresql-$v-pg-mentat | - |
Build
You can build the RPM / DEB packages for pg_mentat using pig build:
Install
You can install pg_mentat directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
- pg_mentat v1.5.7 README
- pg_mentat v1.5.7 control file
- pg_mentat v1.5.6 to v1.5.7 upgrade SQL
- Pigsty package matrix
pg_mentat implements a Datomic-compatible data model and Datalog query engine inside PostgreSQL. It stores immutable facts as typed datoms and exposes schema transactions, Datalog queries, pull expressions, time travel, transaction history, and permanent excision through SQL functions. Use it for applications that need this model; it is not a transparent replacement for relational tables or SQL.
Install and Define a Schema
The recommended convenience aliases live in schema mentat. Schema must be transacted before facts use the new attributes.
Transact and Query Data
mentat.t(edn) applies an ACID transaction and returns its transaction report. mentat.q(query, inputs) compiles a Datalog query to PostgreSQL execution. Use EDN parameters and input bindings rather than interpolating application strings into a query.
Pull, History, and What-If Transactions
mentat.pull returns entity-shaped JSON. mentat.log and mentat.diff expose transaction history, and mentat.mentat_with evaluates a transaction without persisting it. Queries can also be evaluated as of or since a transaction by using the documented database arguments.
Permanent excision is intentionally separate from normal immutable history:
Review the target entity and backups before excision; it permanently removes datoms and is intended for requirements such as privacy erasure.
Important Objects
mentat.t(edn): transact schema or data.mentat.q(query, inputs): execute Datalog.mentat.pull(pattern, eid)andmentat.pull_many(pattern, eids): entity-shaped reads.mentat.entity(eid)andmentat.schema(): inspect an entity or current schema.mentat.log(...)andmentat.diff(...): inspect transaction history.mentat.stats(),mentat.storage(), andmentat.cache_stats(): operational inspection.mentat.subscribe(...): reactive query notifications through PostgreSQLLISTEN/NOTIFY.
The extension stores typed datoms in narrow tables under schema mentat, including reference, integer, string, boolean, floating-point, instant, keyword, UUID, and byte values.
Requirements and Caveats
- Upstream v1.5.7 supports PostgreSQL 13-18. Current Pigsty packages target PostgreSQL 14-18 and are rebuilt with pgrx 0.19.1; upstream’s tagged source declares pgrx 0.17. Treat the packaged binary as the compatibility boundary.
- The extension is not relocatable and does not require
shared_preload_libraries. - The optional
mentatdHTTP/Datomic-wire daemon is an upstream companion program and is not included in the Pigstypg_mentatpackage. SQL use of the extension does not require it. - Datalog compilation, pull recursion, full-text attributes, subscriptions, and history can have very different cost profiles. Inspect generated SQL with the documented explain helper and benchmark representative data.
- Excision bypasses the normal immutable-history model. Restrict privileges and audit its use.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)