Skip to main content

Module pg

Module pg 

Source
Expand description

PostgreSQL GraphBackend (feature graph-pg). PostgreSQL GraphBackend (graph-pg feature).

PgGraph mirrors the bundled SQLite backend over a single mutex-guarded synchronous postgres::Client. Every GraphBackend method matches the SQLite semantics — the composite smart_recall reuses super::recall’s weights and compute_recency for zero drift across backends. Full-text search uses ILIKE substring matching (no PostgreSQL extension required, so the backend runs on any vanilla install), and schema versioning flows through the trait’s current_version / migrate.

§Performance note

ILIKE with a leading wildcard ('%term%') is a sequential scan — the BTREE indexes cannot serve it. This is intentional: keeping the backend extension-free preserves portability (the same rationale as the CJK feature). For very large graphs, callers may opt into indexed substring search by enabling pg_trgm out-of-band (CREATE EXTENSION pg_trgm; CREATE INDEX nodes_trgm ON nodes USING gin ((title || ' ' || body || ' ' || tags) gin_trgm_ops)); the ILIKE queries then use it transparently.

§TLS (graph-pg-tls feature)

PgGraph::connect / PgGraph::connect_config always use postgres::NoTls — servers requiring sslmode=require or stricter reject that handshake. Enabling graph-pg-tls adds PgGraph::connect_native_tls (system trust store, one call) plus PgGraph::connect_tls / PgGraph::connect_config_tls for a caller-supplied postgres::tls::MakeTlsConnect implementor.

Structs§

PgGraph
PostgreSQL-backed GraphBackend over one mutex-guarded connection.