pgexplain 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/cli.js +1031 -75
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +30 -2
- package/dist/index.js +532 -30
- package/dist/index.js.map +1 -1
- package/dist/server.js +3996 -0
- package/dist/server.js.map +1 -0
- package/dist/web/assets/PlanGraph-0P3xGm2e.js +23 -0
- package/dist/web/assets/PlanGraph-C5ap-Sga.css +1 -0
- package/dist/web/assets/index-BqB6p5Pn.js +227 -0
- package/dist/web/assets/index-ByEFSLsN.css +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -137,11 +137,23 @@ interface PlanNode {
|
|
|
137
137
|
ioWriteTime?: number;
|
|
138
138
|
workersPlanned?: number;
|
|
139
139
|
workersLaunched?: number;
|
|
140
|
+
/** Per-worker actuals (EXPLAIN ANALYZE VERBOSE). */
|
|
141
|
+
workers?: WorkerStat[];
|
|
142
|
+
walRecords?: number;
|
|
143
|
+
walBytes?: number;
|
|
144
|
+
walFpi?: number;
|
|
140
145
|
children: PlanNode[];
|
|
141
146
|
metrics: NodeMetrics;
|
|
142
147
|
/** Original JSON node — rules may read rare fields not normalized above. */
|
|
143
148
|
raw: RawPlan;
|
|
144
149
|
}
|
|
150
|
+
interface WorkerStat {
|
|
151
|
+
number: number;
|
|
152
|
+
actualRows?: number;
|
|
153
|
+
actualLoops?: number;
|
|
154
|
+
actualStartupTime?: number;
|
|
155
|
+
actualTotalTime?: number;
|
|
156
|
+
}
|
|
145
157
|
interface JitInfo {
|
|
146
158
|
functions?: number;
|
|
147
159
|
timing?: {
|
|
@@ -163,6 +175,8 @@ interface PlanTree {
|
|
|
163
175
|
root: PlanNode;
|
|
164
176
|
planningTime?: number;
|
|
165
177
|
executionTime?: number;
|
|
178
|
+
/** Result-serialization time in ms (PG17+ EXPLAIN ANALYZE SERIALIZE). */
|
|
179
|
+
serializationTime?: number;
|
|
166
180
|
triggers: TriggerInfo[];
|
|
167
181
|
jit?: JitInfo;
|
|
168
182
|
settings?: Record<string, string>;
|
|
@@ -250,6 +264,11 @@ declare function bottlenecks(tree: PlanTree, n?: number): PlanNode[];
|
|
|
250
264
|
/** A short human label for a node, e.g. "Seq Scan on orders". */
|
|
251
265
|
declare function nodeLabel(node: PlanNode): string;
|
|
252
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Parse EXPLAIN input into one PlanTree per statement, auto-detecting the format:
|
|
269
|
+
* JSON (`[`/`{`) → parseExplainJson, otherwise plain-text `EXPLAIN` output.
|
|
270
|
+
*/
|
|
271
|
+
declare function parseExplain(input: string): PlanTree[];
|
|
253
272
|
/**
|
|
254
273
|
* Parse EXPLAIN (FORMAT JSON) text into one PlanTree per statement.
|
|
255
274
|
* Accepts the standard `[{ "Plan": … }]`, a bare statement object, or a bare plan node.
|
|
@@ -304,6 +323,13 @@ declare class AppError extends Error {
|
|
|
304
323
|
*/
|
|
305
324
|
declare function scrubCredentials(input: string): string;
|
|
306
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Static lock analysis from the SQL text (+ optional plan). PostgreSQL's EXPLAIN
|
|
328
|
+
* does not show locks, so these findings come from the statement shape and node
|
|
329
|
+
* types. Each is an actionable Diagnostic with a PGX_LOCK_* code.
|
|
330
|
+
*/
|
|
331
|
+
declare function analyzeLocks(sql: string, tree?: PlanTree): Diagnostic[];
|
|
332
|
+
|
|
307
333
|
/** Bump on any breaking change to the JSON shape. Consumers can assert on it. */
|
|
308
334
|
declare const JSON_SCHEMA_VERSION = 1;
|
|
309
335
|
|
|
@@ -328,8 +354,10 @@ interface AnalyzeOptions {
|
|
|
328
354
|
statement?: number;
|
|
329
355
|
/** Strip literal values from expressions before analysis (no data leaks downstream). */
|
|
330
356
|
redact?: boolean;
|
|
357
|
+
/** The originating SQL — enables lock analysis (PGX_LOCK_* findings). */
|
|
358
|
+
sql?: string;
|
|
331
359
|
}
|
|
332
|
-
/** Parse → (redact) → compute metrics → run advisor → attach
|
|
360
|
+
/** Parse → (redact) → compute metrics → run advisor (+lock advisor) → attach notices. */
|
|
333
361
|
declare function analyze(input: string, options?: AnalyzeOptions): AnalysisResult;
|
|
334
362
|
|
|
335
|
-
export { type AnalysisContext, type AnalysisResult, type AnalyzeOptions, AppError, DEFAULT_CONFIG, DEFAULT_THRESHOLDS, type Diagnostic, type DiagnosticLocation, type Domain, ExitCode, FORMATS, type Format, JSON_SCHEMA_VERSION, type JitInfo, type NodeMetrics, type PgExplainConfig, type PlanNode, type PlanTree, type RawPlan, type Remediation, type RemediationCommand, type RenderOptions, type Rule, type Severity, type Thresholds, type TriggerInfo, analyze, bottlenecks, computeMetrics, executionMs, flatten, isFormat, nodeLabel, parseExplainJson, render, runAdvisor, scrubCredentials, walk };
|
|
363
|
+
export { type AnalysisContext, type AnalysisResult, type AnalyzeOptions, AppError, DEFAULT_CONFIG, DEFAULT_THRESHOLDS, type Diagnostic, type DiagnosticLocation, type Domain, ExitCode, FORMATS, type Format, JSON_SCHEMA_VERSION, type JitInfo, type NodeMetrics, type PgExplainConfig, type PlanNode, type PlanTree, type RawPlan, type Remediation, type RemediationCommand, type RenderOptions, type Rule, type Severity, type Thresholds, type TriggerInfo, type WorkerStat, analyze, analyzeLocks, bottlenecks, computeMetrics, executionMs, flatten, isFormat, nodeLabel, parseExplain, parseExplainJson, render, runAdvisor, scrubCredentials, walk };
|