Skip to main content
loadwise perf finds repeated backend work and avoidable React, Vue and Angular rendering work in source code, OpenTelemetry traces and executed database plans. Findings for loops and repeated spans carry an Impact: line that says which side is measured and which is estimated (~); a millisecond figure is never printed without a measurement behind it. Sample text finding with its fix diff:

Source checks

Run in the directory containing tsconfig.json or jsconfig.json, pass -p path/to/config.json, or give explicit JS/TS files (checked with ES2022 and NodeNext defaults). A project check follows project references. JavaScript files that the found config leaves out because allowJs is off are still checked with the standalone defaults and named in a note; a config passed with -p is checked exactly as it lists its files. Install the application’s driver declarations and generate its Prisma client first: unresolved types, wrappers and deferred callbacks can hide findings. Test, seed and operator-tooling sources (scripts, seeds, prisma/seed.ts, *.seed.ts, deployment, migrations) make per-item query, index, serial-await, Redis KEYS, pure-JavaScript hashing, Prisma dependent-write and Drizzle whole-table-write findings contextual. prisma-count-for-existence findings may carry idField, the model’s single primary-key field that the fix selects. Engines: one-shot checks use Microsoft’s Go-based TypeScript 7 compiler on Node.js 22.13+ with the optional native package for your platform (same findings; 1.7–2.2 times faster on the 3,200-file benchmark in PERFORMANCE.md, and the gain depends on the project) and fall back to TypeScript 6.0.3 with a stderr note when TypeScript 7 rejects the configuration (for example baseUrl or moduleResolution: "node10"). --engine native (alias --native) requires TypeScript 7 and reports incompatible configuration as exit 2; --engine js always uses TypeScript 6.0.3. perf --json names the engine in engine ("js" or "native"). --watch uses TypeScript 6.0.3 on a single project; with --watch --json each completed scan writes one JSON line. If your npm registry omits the optional native TypeScript packages, install with those dependencies omitted and scan with the JavaScript compiler:
Automatic engine selection also falls back to JavaScript when the optional binary is absent. The report sets engine to "js". Explicit native mode (--engine native or --native) requires the matching TypeScript binary and exits 2 if it is missing. --omit=optional also removes @ast-grep/cli. JavaScript and TypeScript source checks still run, but polyglot checks skip Python, Go, Java, C#, and Rust until the optional scanner is installed.

ORM and query integrity checks

Covered libraries: Prisma, Drizzle ORM (PostgreSQL, MySQL and SQLite core APIs), TypeORM, Sequelize, Mongoose, Knex, Kysely and node-postgres. Building an array of lazy Prisma queries alone is quiet, and same-tick findUnique calls that Prisma batches itself are left to runtime traces.

Project-defined access policy

Put the policy in the performance section of loadwise.config.json beside the selected project config (in the working directory for explicit source files), or pass --policy path/to/file.json. A policy can use just the sections the project needs: parallelReads (groups of exports that may start together, used by known-reads-awaited-serially), fireAndForget (helper names that floating-promise accepts without an await), and prismaScopes, drizzleScopes and kyselyScopes (see Project-defined row scopes). Duplicate JSON keys within the same object produce a configuration error. Example policy

Async work and sorting

Schema-aware index checks

The source checker reads the project’s ORM schema (Prisma, Drizzle, TypeORM, Sequelize, Mongoose) and compares declared indexes with the queries it finds. Each suggested index carries one explicit name, used both in the ORM snippet and in the CREATE INDEX CONCURRENTLY statement, so building it by hand and then generating a migration does not create a duplicate. Pass --schema snapshot.json (written by perf db --schema-snapshot) to refine findings with real table sizes and the measured round trip, which also feeds the Impact line of *-query-in-loop findings.

Polyglot source checks

npx loadwise perf polyglot src accepts directories or individual .py, .go, .java, .cs, .rs, .rb and .php files and needs the optional ast-grep native binary. npx loadwise rel polyglot src runs its reliability patterns for Python, Go, Java, C#, Rust and Kotlin (.kt, .kts). Language-specific aliases and wrappers can fall outside a pattern.

Trace checks in other languages and databases

npx loadwise perf traces <file> reads one local OTLP, Jaeger, or Zipkin v2 JSON export. For OpenTelemetry Collector output with multiple JSON lines, pass the export object for the request. --threshold sets how many similar sibling calls form a finding. Try npx loadwise perf traces node_modules/loadwise/examples/repeated-db.otlp.json. Reports contain span IDs and counts and omit raw SQL, parameters and keys. Check scannedSpans and eligibleDbSpans when interpreting a clean result.
  • duplicate-key-read (medium): A trace repeats the same key or row read under one parent span.
  • redis-keys-scan (high): A trace shows a Redis KEYS command scanning the keyspace.
  • redis-repeated-read (medium): A trace shows repeated sibling Redis GET or HGET calls.
  • repeated-db-span (high): A trace shows many similar sibling database calls under one parent.

Executed query plans

npx loadwise perf plan <file> reads a JSON file from PostgreSQL EXPLAIN (ANALYZE, FORMAT JSON) or MongoDB explain("executionStats"), for example node_modules/loadwise/examples/postgres-plan.json, and reports the stage path and observed counts (MongoDB: classic stages and selected slot-based scan, filter and skip shapes). Planner estimates alone, and layouts where a scan cannot be attributed, exit 2. PostgreSQL’s ANALYZE option executes the statement when you collect the plan.

Database inspection (optional)

npx loadwise perf db is the only command that connects to a database. Point it at a staging or read replica database, never a primary you cannot afford to touch. It uses the project’s own pg, mysql2 or mongodb package. The connection comes from the environment, never a flag: DATABASE_URL (or the variable named by --url-env), else DB_HOST, DB_PORT, DB_USER or DB_USERNAME, DB_PASSWORD and DB_NAME or DB_DATABASE. --env-file FILE reads those variables from a file without loading them into the process environment. --engine postgres|mysql|mongo is needed with DB_HOST variables when DB_PORT is not the engine default. For MySQL without TLS, mysql2 3.26.0 and later refuse to fetch the server’s RSA public key, which an account that has not logged in since the server started needs; connect with TLS (preferred), or opt in with DB_ALLOW_PUBLIC_KEY_RETRIEVAL=1 or ?allowPublicKeyRetrieval=true on the URL. Opting in lets a man-in-the-middle on an untrusted network read the password. It is off by default.
--include-contextual, --ignore RULE and --json work as in the other commands. For a local SQLite file, use loadwise perf db --engine sqlite --sqlite-file app.sqlite --queries queries.sql. Loadwise opens the file read-only with Node’s SQLite module and returns EXPLAIN QUERY PLAN details for SELECT statements. It skips other statements, leaves the SELECTs unevaluated, and uses no project driver. On Node 22, Node prints an ExperimentalWarning for its SQLite module on each run; the warning does not affect the result. Safety. Sessions and transactions are read-only, with a 5 s statement timeout on PostgreSQL, and only SELECT, INSERT, UPDATE and DELETE can be explained. EXPLAIN ANALYZE runs only for a plain SELECT (a WITH that modifies data is refused). MongoDB uses a command allowlist. Error text replaces the connection URL, host, user, password and resolved IP addresses with [redacted]. Usage counters come from the node that answered, so an index unused here may still be used on a replica. --measure blocks writes to the table while each index builds. It refuses a connection variable or database name matching /prod/i, a replica, an unknown table size and any table over 5,000,000 estimated rows, and it needs the long confirmation flag. With the HypoPG extension, suggested indexes are also checked hypothetically. Output labels every figure as measured (timed on your database) or estimated (planner statistics, a model or HypoPG).