Skip to main content

Interface: QueryPlanLoggerOptions

Defined in: src/observability/QueryPlanAnalyzer.ts:64

Options for createQueryPlanLogger.

Properties​

adapter​

adapter: IDbAdapter

Defined in: src/observability/QueryPlanAnalyzer.ts:69

The live adapter to issue EXPLAIN queries against. Must be the same adapter used by the DbContext.


analyze?​

optional analyze?: boolean

Defined in: src/observability/QueryPlanAnalyzer.ts:78

When true, runs EXPLAIN ANALYZE (executes the real query for accurate timing). When false (default), runs EXPLAIN only without re-executing the query.

Caution​

EXPLAIN ANALYZE actually executes the SQL — only use it on SELECT queries.

Default Value​

false

thresholdMs?​

optional thresholdMs?: number

Defined in: src/observability/QueryPlanAnalyzer.ts:85

Only run the planner when actual query execution time exceeds this threshold in ms. Leave undefined to always run the planner on matching queries.

Default Value​

undefined

operations?​

optional operations?: ("SELECT" | "WITH" | "UPDATE" | "INSERT" | "DELETE" | "ALL")[]

Defined in: src/observability/QueryPlanAnalyzer.ts:91

SQL operation prefixes to analyze.

Default Value​

['SELECT'] — INSERT/UPDATE/DELETE excluded by default to avoid double-execution.

warnOnSeqScan?​

optional warnOnSeqScan?: boolean

Defined in: src/observability/QueryPlanAnalyzer.ts:97

Emit a warning log line when a Seq Scan (full table scan) is detected.

Default Value​

true

colorize?​

optional colorize?: boolean

Defined in: src/observability/QueryPlanAnalyzer.ts:103

Whether to include ANSI terminal colors in output.

Default Value​

auto-detected from process.stdout.isTTY

logger?​

optional logger?: (message) => void

Defined in: src/observability/QueryPlanAnalyzer.ts:108

Custom log destination. Defaults to console.log.

Parameters​

ParameterType
messagestring

Returns​

void


onPlan?​

optional onPlan?: (plan) => void

Defined in: src/observability/QueryPlanAnalyzer.ts:114

Called after each plan is computed, with the structured result. Use to push plan data to a metrics pipeline or alerting system.

Parameters​

ParameterType
planQueryPlanResult

Returns​

void