Primary Key Advisor
Reviews the primary key on each table and says what it will cost you.
Loading the tool…
How to use this tool
- Paste the CREATE TABLE statements for the tables you want reviewed.
- Pick the engine — a wide key costs considerably more on InnoDB than elsewhere, and the advice changes accordingly.
- Select Review the keys.
- Deal with any table reported as having no primary key first; that is the only finding here that breaks correctness rather than performance.
What primary key advisor does
The primary key is the one decision on a table that is genuinely hard to change later, because everything else points at it. A random key such as a version 4 UUID scatters inserts across the whole index instead of appending to the end, so page splits never stop and the cache holds a fraction of what it would. A wide key is copied into every secondary index on the table under InnoDB and into every clustered index lookup elsewhere. A composite key can be used for a lookup on its first column and not on its last. And a table with no key at all cannot be updated a row at a time with confidence, replicated reliably, or referenced by anything.
This page reads your CREATE TABLE and reports on each table in turn: the key, its width in bytes, whether it is monotonic or random, what its width does to the secondary indexes it will carry, whether the column order of a composite key matches what you are likely to filter on, and whether any key column has been left nullable. Tables with no key get the nearest candidates the DDL offers. Choose the engine before running it — the consequences of a wide key are considerably worse on InnoDB than elsewhere, and the report says so.