Postgres missing foreign key index checker

Drop your migrations or schema.prisma, or paste a schema, to list foreign key columns that have no index.

Run the check

Drop a project folder or files here

node_modules, .git, virtualenvs and build folders are skipped. Limit 25 MB / 5,000 files.

The Python engine (Pyodide, a few MB, cached by your browser) loads when you start.

The mistake

Assuming PostgreSQL indexes foreign keys. It creates an index for PRIMARY KEY and UNIQUE constraints, but not for the referencing column(s) of a FOREIGN KEY.

Why it is dangerous

Without one, every DELETE (or key UPDATE) on the referenced table has to scan the referencing table to check or cascade matching rows, and joins and filters on the column (WHERE user_id = $1, the usual access path) scan it too. It is invisible on small tables and turns into slow deletes, long lock waits and slow pages as the table grows.

How to fix it

Create an index on the referencing column (concurrently, if the table already holds data), or add @@index([userId]) in Prisma:

CREATE INDEX CONCURRENTLY IF NOT EXISTS orders_user_id_idx ON orders (user_id);

A composite index whose first column is the foreign key column also covers it.

What this checker looks for

This page runs pg-launch-check, which reads SQL migrations, schema.prisma and app code (Prisma, Drizzle, pg, SQLAlchemy, Django). The rules most relevant to this page:

RuleWhat it finds
PGL001Foreign key column without an index
PGL007Table without a primary key
PGL008UUID primary key stored as text
PGL009Money stored as a floating-point type
PGL010timestamp without time zone

Every finding has a rule id, a severity, file:line, the offending line (secrets masked), why it matters and how to fix it. Run pg-launch-check rules for the full list.

FAQ

Does it read schema.prisma?

Yes. Prisma relations without a matching @@index are reported, for PostgreSQL datasources.

Does it connect to my database?

No. The schema is rebuilt by replaying your migrations in order, in memory.

Are my files uploaded anywhere?

No. The checker is Python running inside your browser tab (Pyodide, WebAssembly). Your files are read with the browser's File API and written into an in-memory file system that exists only in this tab. Your files are never sent anywhere. The only network requests load the Python runtime and the checker code, plus Google Analytics page-view counting, which never sees your files. You can disconnect from the internet after the engine has loaded and the scan still works.

Is a clean report a guarantee?

No. It is a static check for known patterns, not a penetration test. A clean report means none of these patterns were found, nothing more.

Can I run the same check on my machine or in CI?

Yes. Every checker on this site is an open-source command-line tool (MIT licence, Python 3.10+ standard library only). The results here are the same as `scan --json` on the command line, except for checks that need git (whether a file is committed or ignored), which cannot run in a browser.