pg_redact is a Postgres extension that uses content-aware PII detection to redact personal information in free-text fields. It combines regex pattern matching to identify candidate snippets with Jev, TypeSafe's classification model, to determine what constitutes PII in context, then applies role-based masking rules via SQL functions.
An AI agent was tasked with optimizing a slow PostgreSQL query across three database servers. While all runs eventually produced a 10x faster solution, completion times varied from 143 to 513 seconds due to unnecessary query re-runs, index creation, and result verification—behaviors the agent adopted without explicit instructions.