InnoDB without a PRIMARY KEY

InnoDB invents a hidden clustered key. Give it an explicit PK instead.

InnoDB stores rows in the clustered index. Without an explicit primary key it creates a hidden 6-byte DB_ROW_ID (GEN_CLUST_INDEX).

Costs

  • Secondary indexes point at an ID you cannot reference in SQL
  • You lose control of clustering order
  • Debugging and tooling get harder

Fix

ALTER TABLE events
  ADD COLUMN id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

Natural keys only if truly immutable and compact. UUID-as-PK has locality costs — choose deliberately.

Rule: every InnoDB table has an explicit PK. Align clustering with hottest range scans when you can.