AI assistance
psql+ puts an AI assistant one keystroke away. Type ?? followed by a question in plain English, and it answers inline — no separate window, no copy-pasting into a chat.
Asking a question
The assistant is invoked with the ?? prefix. Ask whatever you'd ask a colleague looking over your shoulder:
?? why is this query not using my index
It reads your last query and the surrounding schema — table definitions, column types, and the indexes that exist — then explains the likely cause. Common findings include:
- A non-SARGable predicate — a function wrapped around an indexed column (for example
WHERE lower(email) = …), which the planner can't satisfy from the plain index. - A type mismatch — comparing a
bigintcolumn against atextliteral forces a cast, and the cast hides the column from the index. - Low selectivity — when a predicate matches a large fraction of rows, a sequential scan is genuinely cheaper, so the planner skips the index on purpose.
Example exchange
=# SELECT * FROM orders WHERE date(created_at) = '2026-05-01';
=# ?? why is this query not using my index
You have an index on orders(created_at), but the predicate wraps the
column in date(created_at). That makes it non-SARGable: the planner
can't use the btree index on a computed expression, so it falls back
to a sequential scan.
Try a range predicate that leaves the column bare:
WHERE created_at >= '2026-05-01'
AND created_at < '2026-05-02'
Or add an expression index on date(created_at) if you query it this
way often.
What it will and won't do
The assistant is built to help you understand what's happening, and nothing more:
- It is opt-in. Nothing is sent until you type
??. - It never runs or mutates statements on its own. It reads your query text and schema, suggests, and explains — you decide what to execute.
- It is never a scoring engine. In pgpg's incident scenarios, the AI never grades, gates, or judges your work. It's a learning aid, kept entirely separate from how scoring works.
Configuration
You control the AI provider and credentials. In ~/.config/rillence/config.toml:
[ai]
enabled = true
provider = "anthropic"
# psql+ reads the key from this environment variable — never from disk.
api_key_env = "ANTHROPIC_API_KEY"
To turn the feature off entirely, set enabled = false — ?? then becomes a no-op and no schema or query text ever leaves your machine. Point provider at a self-hosted or alternative model if you'd rather not use the default.