The pure pieces of the opt-in EXPLAIN (see ForgeOpsTracker.QueryPlanner): which statements are
safe to EXPLAIN, the rate limits, masking a plan, and building the POST /api/v1/query_plans
body. Also the db.system name for an Ecto adapter, and the data a database span carries.
Summary
Functions
Whether key (a masked statement) may be EXPLAINed at now_ms (a monotonic millisecond time):
each key at most once per 10 minutes, and at most 10 per rolling minute overall. Returns the
decision and the updated state.
The lowercase db.system for an Ecto adapter module (Ecto.Adapters.Postgres is
"postgresql", MyXQL is "mysql", SQLite3 is "sqlite", Tds is "mssql") or a name
given as a string, or nil when unknown.
Whether a statement is safe to EXPLAIN: after comments and leading whitespace it starts with
SELECT, has no second statement (no ; except one at the very end), no locking clause (FOR UPDATE, FOR SHARE, FOR NO KEY UPDATE, FOR KEY SHARE), and no INSERT, UPDATE, DELETE or
MERGE anywhere (a data-modifying CTE).
The masked statement a database span carries as "db.statement": SqlStatement.mask/1, capped
at exactly 4000 characters.
Every string in the plan masked with SqlStatement.mask/1 (a plan's "Filter" or
"Index Cond" repeats the query's literals); numbers, keys and structure unchanged.
The largest serialized plan that's sent; a bigger one is dropped.
Empty rate limit state.
The POST /api/v1/query_plans body, or nil when the plan isn't usable (not the JSON array
Postgres returns) or its serialized form is over 64 KB. plan is that JSON text or already
decoded.
The db system of an Ecto repo, from its adapter; nil when it can't be told.
data plus "db.statement" (already masked) and "db.system", each only when known.
The SET LOCAL statement_timeout value the EXPLAIN runs under.
Types
Functions
Whether key (a masked statement) may be EXPLAINed at now_ms (a monotonic millisecond time):
each key at most once per 10 minutes, and at most 10 per rolling minute overall. Returns the
decision and the updated state.
The lowercase db.system for an Ecto adapter module (Ecto.Adapters.Postgres is
"postgresql", MyXQL is "mysql", SQLite3 is "sqlite", Tds is "mssql") or a name
given as a string, or nil when unknown.
Whether a statement is safe to EXPLAIN: after comments and leading whitespace it starts with
SELECT, has no second statement (no ; except one at the very end), no locking clause (FOR UPDATE, FOR SHARE, FOR NO KEY UPDATE, FOR KEY SHARE), and no INSERT, UPDATE, DELETE or
MERGE anywhere (a data-modifying CTE).
The masked statement a database span carries as "db.statement": SqlStatement.mask/1, capped
at exactly 4000 characters.
Every string in the plan masked with SqlStatement.mask/1 (a plan's "Filter" or
"Index Cond" repeats the query's literals); numbers, keys and structure unchanged.
@spec max_plan_bytes() :: pos_integer()
The largest serialized plan that's sent; a bigger one is dropped.
@spec new_limits() :: limits()
Empty rate limit state.
@spec payload( ForgeOpsTracker.Configuration.t(), String.t(), String.t(), term(), number(), DateTime.t() ) :: map() | nil
The POST /api/v1/query_plans body, or nil when the plan isn't usable (not the JSON array
Postgres returns) or its serialized form is over 64 KB. plan is that JSON text or already
decoded.
The db system of an Ecto repo, from its adapter; nil when it can't be told.
data plus "db.statement" (already masked) and "db.system", each only when known.
@spec statement_timeout() :: String.t()
The SET LOCAL statement_timeout value the EXPLAIN runs under.