pg_sage
pg_sage · Legacy preload C extension for DBA monitoring and guarded actions
Overview
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
- Current project README and architecture boundary
- Version 0.5.0 extension SQL
- Legacy extension entry point
- Current reverse specification
pg_sage 0.5.0 is the cataloged, preload-based C extension from the pg_sage repository. It collects snapshots, analyzes database health, records findings and actions, and exposes control and JSON helper functions in the fixed sage schema. The current upstream product has since moved to a standalone Go sidecar and explicitly says no PostgreSQL extension is required; do not mix the two architectures.
Core Workflow
For an existing 0.5.0 extension deployment, preload both its library and pg_stat_statements, restart PostgreSQL, then create the extension in the target database:
Use observation or recommendation behavior first, review every proposed SQL action, and verify emergency-stop handling before any autonomous mode.
Important Objects
sage.snapshots,sage.findings, andsage.explain_cachestore collected evidence and analysis results.sage.action_logrecords executed SQL and rollback metadata.sage.configstores runtime configuration, including endpoints and autonomous mode.sage.status,sage.emergency_stop, andsage.resumeexpose operational control.sage.explain,sage.suppress,sage.diagnose, andsage.briefingexpose analysis workflows.sage.health_json,sage.findings_json,sage.schema_json, and related helpers support the sidecar-facing JSON surface.
Security and Lifecycle Notes
The legacy library installs executor hooks, shared memory, libcurl, and four background workers, and it requires superuser installation. It can collect query text and plans, contact an LLM endpoint, retain API-key-related configuration, and execute recommended SQL, so limit schema access and protect configuration and logs as secrets. The current README and reverse specification describe a wire-protocol sidecar instead of this extension. Treat 0.5.0 as a legacy deployment boundary and migrate deliberately rather than applying current sidecar instructions to the C module.