Info
Open the page on your phone

Clustered and Non-Clustered Indexes in MySQL

Clustered index:

  • One per table.
  • Physically organizes data on disk.
  • Used for the primary key (or unique index if the primary key is missing).
  • Provides fast access to records by key value.
  • Example: `PRIMARY KEY (id)`.
  • Non-clustered index:

  • Can be many per table.
  • Does not affect the physical location of data.
  • Used to speed up searches on fields that are not part of the clustered index.
  • Consists of two parts: a B-tree and an overflow list.
  • Example: `INDEX (name)`.
  • Differences:

    A table showing the differences between a clustered and a non-clustered index