Scan your whole stack
From OX Research Newsroom
Are you using plancliff?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.1.0
plancliff was last scanned on 26 Nov 2026 at version 0.1.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.1.0 LATEST | 26 Nov 2026 | No rules fired |
Findings for v0.1.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.1.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Find the PostgreSQL queries that become hundreds of times slower once Postgres switches a prepared statement to its generic plan, and prove the fix before production finds them for you.
$ plancliff scan postgresql://localhost/openfga_copy --stats-from postgresql://localhost/openfga_prod
1 queries from pg_stat_statements of openfga_prod, costliest first
CLIFF 945.8× generic 48.24 ms, custom 0.05 ms SELECT store, object_type, object_id, relation, _user, user_… [12 calls, queryid -1250848085573255456]
triggered by the frequent values: store1, document, obj1188, viewer, group:hot1#member, userset, … (31 values)
confirmed: Postgres switched to the generic plan at prepared call 6 (15/20 generic); calls 2-5 0.47 ms, calls 7-20 40.78 ms
fix ✓ SET LOCAL plan_cache_mode = force_custom_plan; -- in the same transaction, just before this query
proven: calls 7-20 0.53 ms, 0/20 generic
fix ✓ never prepare this query; with psycopg 3: cursor.execute(query, params, prepare=False)
proven: calls 7-20 0.62 ms
Drivers prepare the queries you run often: psycopg 3 from the 6th call, asyncpg always, the PostgreSQL JDBC driver after a few executions. After 5 executions of a prepared statement, Postgres may switch to a generic plan, built once without looking at the parameter values. It decides by comparing estimated costs, and on a skewed column the estimate can be badly wrong: the query that took a millisecond now takes hundreds, from the 11th call of your application onwards, and nothing in the code changed.
Two public examples, both reproduced on their real schema in labo/:
SELECT … FOR UPDATE, reported going from 13 ms to 43 s. Reproduced through psycopg 3 with default settings: 0.6 to 1 ms for calls 1 to 10, 242 ms at call 11.DELETE. Reproduced the same way: 0.8 to 1.3 ms for calls 1 to 10, then 2.1 to 2.3 s per call.The usual cure, plan_cache_mode = force_custom_plan for the whole database, makes every query plan on every call: +78% on a 4-table join in the lab. The point is to know which queries need it.
pg_stats. It runs the query with the generic plan forced, then with the custom plan forced, best of 3 after a warm-up. At least 10× and 5 ms slower is a cliff.auto mode, as your driver would. The cliff is confirmed when Postgres actually switches to the generic plan and calls 7-20 are at least 10× slower than calls 2-5.Everything runs inside transactions that are rolled back, writes included.
pip install plancliff # or: uv tool install plancliff, or run it once with: uvx plancliff
Python 3.11 or later. PostgreSQL 14 or later; tested on 14, 15, 16, 17 and 18.
# recommended: the queries production actually runs, read from its pg_stat_statements, measured on a copy
plancliff scan postgresql://user@host/app_copy --stats-from postgresql://readonly@prod/app
# a database that has its own statistics, such as a staging database under real traffic
plancliff scan postgresql://user@host/app
# or a file: one query per block, blocks separated by a blank line, $1, $2… placeholders, an optional "-- name" line
plancliff scan postgresql://user@host/app_copy queries.sql
Scan a copy with realistic data: a cliff only shows on data as skewed as production's. --stats-from connects with default_transaction_read_only and only reads pg_stat_statements; a restored copy has no statistics of its own.
| Verdict | Meaning | Fails the run |
|---|---|---|
cliff |
confirmed: Postgres switches to the generic plan and the query slows down; also when the verification could not run | yes |
latent |
the forced generic plan is slow, but Postgres keeps the custom plan today; new statistics could change that | no |
ok |
the generic plan is not much slower | no |
error |
the query could not be tested: empty table, duplicate key, a text parameter that matches no column | no |
Exit code: 1 when at least one cliff is found, 0 otherwise, 2 on a usage error. A CI job can run it against a staging copy and fail on a new cliff.
Both fixes plancliff proves touch one query only; every other query keeps the plan cache.
# any driver: force the custom plan for this transaction only
with conn.transaction():
conn.execute("SET LOCAL plan_cache_mode = force_custom_plan")
rows = conn.execute("select id from jobs where status = %s order by created_at limit 10", ("pending",)).fetchall()
# psycopg 3: never prepare this one query
cur.execute("select id from jobs where status = %s order by created_at limit 10", ("pending",), prepare=False)
Both make Postgres plan this query on each call. That costs a little: on Temporal's v2 task cleanup, 2.56 ms per call before the switch, 3.08 ms with SET LOCAL, against 68 ms without a fix.
plancliff keeps the application's parameterised queries (select, insert, update, delete, with, merge), costliest first (--top, 100 by default), and skips utility statements and queries on system objects (pg_*, information_schema). The extension must be loaded (shared_preload_libraries) and installed (CREATE EXTENSION pg_stat_statements).
pg_stat_statements replaces constants with $n: a limit 10 written in the code is stored as limit $2, and a parameterised limit hides the cliff from the generic plan. So an integer parameter that matches no column is also tried as a constant, and the worse verdict is kept, with a note. When your code really passes that value as a parameter, this can report a cliff that only exists in the constant form.
Without the pg_read_all_stats role, the statements of other roles are stored as <insufficient privilege>: plancliff counts them and says so (GRANT pg_read_all_stats TO <role>;), rather than silently scanning fewer queries; when it can read none at all, it exits with 2 instead of reporting an empty, green scan.
--timeout).FOR UPDATE read locks rows while it runs, even rolled back, and a live application would wait. --allow-busy overrides this for a shared staging database you accept to slow down. plancliff's own connections are named plancliff and do not count.--stats-from only reads, through a read-only connection.| Option | Effect |
|---|---|
--stats-from DSN |
read pg_stat_statements from this database instead of the scanned one |
--top N |
number of pg_stat_statements queries to scan, costliest first (100) |
--format json |
one JSON document on stdout: source, settings, every query with its measure, verification and fixes, a summary |
--no-verify |
skip the 20 calls; every measured cliff then counts as a cliff, without a proven fix |
--threshold, --min-gap-ms |
the cliff rule, 10× and 5 ms by default |
--timeout |
statement timeout per execution, in seconds (30) |
--allow-busy |
scan even when other sessions are connected |
-v |
also list the queries that are fine |
--color auto\|always\|never |
coloured in a terminal, plain when piped; NO_COLOR=1 and FORCE_COLOR=1 are honoured |
--version |
print the version |
error: inserts that hit an existing key with the value tried, empty tables, text parameters that match no column. On Temporal's 94 queries, 11 are untestable.IN ($1 /*, ... */) in pg_stat_statements; plancliff replays it with a single value.ROLLBACK: an application that rolls back often is not exposed, until it starts committing more.pg_stat_statements on the scanned database.Every figure in this README comes from a script in labo/ that can be run again: the two public victims reproduced on their real schema with skewed data, the 94 queries of Temporal 1.31.1 extracted from its Go code, and the cost of the global setting. The test suite runs against PostgreSQL 14 to 18 and Python 3.11 to 3.13 on every push.
MIT, see LICENSE.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.