Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Plinth — Index Advisor for Prisma, Drizzle and TypeORMNew to Visual Studio Code? Get it now.
Plinth — Index Advisor for Prisma, Drizzle and TypeORM

Plinth — Index Advisor for Prisma, Drizzle and TypeORM

Plinth

|
2 installs
| (0) | Free
Catch the missing index in your editor, not in your incident channel. Flags Prisma, Drizzle and TypeORM queries that slow down at production scale on PostgreSQL and MySQL, and writes the exact migration to fix them.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Plinth for VS Code

Catch the missing index in your editor, not in your incident channel.

Plinth reads your ORM queries as you write them, finds the ones that will slow down at production scale, and writes the exact change to fix them.

PostgreSQL MySQL
Prisma ✓ ✓
Drizzle ✓ ✓
TypeORM ✓ ✓

What it catches

  • Unindexed filters and sorts: a filter plus sort with no composite index behind it.
  • Foreign keys without an index: PostgreSQL never creates them; MySQL does only for real constraints.
  • Unbounded list queries: no take / limit, so the result grows with the table.
  • Queries in loops: one round trip per item (it knows Prisma batches findUnique).
  • Redundant indexes: an index that duplicates another, or whose columns are the leading columns of a wider index. The wider one serves every query the narrow one does, so the fix removes it and writes the DROP INDEX migration. No statistics needed.
  • Unused indexes: with synced database statistics, an index the database has not read through in weeks, while every write still maintains it.

It reads Prisma Client calls, Drizzle's query builder and relational API, and TypeORM repositories, EntityManager calls and createQueryBuilder chains (including a builder kept in a variable). It skips tests, seeds, scripts and migrations, which never see production traffic. Raw SQL is not read.

Indexes cost writes, so Plinth counts them

Every index is updated on each insert and delete, and on each update to its columns. Plinth weighs that before it suggests one:

  • Every suggested index states its write cost: which writes maintain it, and how many indexes the table already has.
  • It extends before it adds. When an existing index on (region) can grow into (region, status, createdAt), Plinth suggests that and tells you to drop the old one, so writes still maintain one index, not two.
  • It plans each table, not each query. Plinth looks at every query on a table across the project and suggests the fewest indexes that serve them all. A filter on status shares the (status, createdAt) index another query needs, and an index on (userId, createdAt) also covers the userId foreign key, which then gets no finding of its own. Every finding names the other call sites its index serves, and its quick fix adds that one index.
  • It keeps a budget per table. A table should carry at most five secondary indexes (set "maxIndexes" per table to change it). When the plan would go past that, the indexes serving the most queries are kept and the rest are reported at low confidence with the reason. A query measured as hot keeps its index anyway. Redundant indexes count as already dropped.
  • It weighs how often the query runs against how often the table is written. With synced statistics (below), a query that runs 100+ times an hour keeps its index even on a busy table, while a query that runs less than hourly on a table taking 1,000+ row writes an hour drops in confidence. Without a per-query count, a table that writes 10× more rows than it reads drops too.
  • It trusts measurements over guesses. In order: how often this query ran, the table's measured reads and writes, your "writeHeavy": true declaration, and last, call sites in the code. Call sites are shown on every warning ([1 read : 5 writes in code]) but never lower confidence: one endpoint hit a million times an hour outweighs fifty admin writes. Tests, seeds, scripts and migrations aren't counted.
  • It stays quiet when an index wouldn't pay off: small tables, and columns with only a handful of distinct values.

The fix, in your ORM's own terms

ORM Schema change Migration
Prisma @@index([status, createdAt]) in the model prisma/migrations/<timestamp>_add_…_index/migration.sql
Drizzle index("…").on(t.status, t.createdAt) in the table run drizzle-kit generate
TypeORM @Index("…", ["status", "createdAt"]) on the entity src/migrations/<timestamp>-Add…Index.ts (your migrations path)

Index names are explicit and identical in the schema and the SQL, so your migration tool reports no drift. On PostgreSQL the SQL uses CREATE INDEX CONCURRENTLY; on MySQL, online DDL (ALGORITHM=INPLACE LOCK=NONE). TypeORM migrations build concurrently only when your DataSource sets migrationsTransactionMode to "each" or "none", because CONCURRENTLY cannot run inside a transaction.

Confidence and table sizes

Static code can't see how big your tables are, so every finding carries a confidence level. Raise it by declaring rough sizes in plinth.config.json next to your package.json. Keys can be model, entity or table names:

{
  "tables": {
    "orders": { "rows": 5000000, "distinct": { "status": 4 } },
    "events": { "rows": 90000000, "writeHeavy": true, "maxIndexes": 3 }
  }
}

Or run Plinth: Copy table-size query and execute it on the production primary. It reads planner statistics and activity counters only (PostgreSQL pg_class/pg_stats/pg_stat_user_tables/pg_stat_user_indexes, MySQL information_schema/performance_schema), never row contents, and returns that JSON ready to paste. Tables declared under 10k rows are left alone.

Measured traffic

The same query records what the database counted since its statistics were last reset: reads of each table, rows inserted, updated and deleted, and how often each index was used. plinth-ci sync-stats also records how often each query shape ran, from pg_stat_statements or MySQL's statement digests. Warnings then show measured rates, e.g. [query ~28/s · rows written ~15/s measured].

  • Run it on the primary. A PostgreSQL standby counts only its own reads and no writes; Plinth notices and ignores its write counters.
  • Rates need a known window. PostgreSQL knows it only after the statistics have been reset once (stats_reset); until then Plinth shows totals and compares reads with writes.
  • An index is reported unused only after 7 days of counters (low confidence) or 30 days (medium), never from a standby, and never for unique or primary keys. Counters are per server, so check replicas that serve reads before dropping one.

Plinth reads the database from your ORM config (Prisma provider, Drizzle pgTable/mysqlTable, TypeORM DataSource type). If it can't, set "dialect": "postgresql" or "mysql" in plinth.config.json.

Silencing a finding

// plinth-ignore-next-line unbounded-query
const all = await prisma.country.findMany();

Use Ignore … here from the lightbulb, or // plinth-ignore-file at the top of a file.

Settings

Setting Default Description
plinth.enable true Analyze as you type
plinth.schemaPath auto Prisma only: schema.prisma or a prisma/schema/ folder
plinth.minConfidence low Hide findings below this confidence

Privacy

Everything runs locally. Your code and schema never leave your machine. Plinth collects no telemetry.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft