{
  "slug": "clustered-index",
  "term": "Clustered index",
  "aliases": [
    "Clustering index"
  ],
  "definition": "A clustered index stores a table's rows in a key-ordered index structure that serves as the table's main storage organization.",
  "note": "InnoDB uses the primary key for clustering, otherwise the first UNIQUE index whose key columns are all NOT NULL, otherwise a generated hidden row identifier. [innodb-indexes]\n\nClustering and the logical primary-key constraint are different concepts. PostgreSQL indexes are separate from the heap, even when enforcing a primary key. CLUSTER physically reorders that heap once; subsequent writes do not maintain the clustering order. [pg-secondary] [pg-cluster]\n\nSQLite WITHOUT ROWID uses a primary-key index b-tree for the table itself. Record payload can occur in internal cells as well as leaves, so leaf-only storage is not a universal property of clustered layouts. [sqlite-format]\n\nStorage order is not a SQL result-order guarantee. SQLite requires an ORDER BY clause when a defined output order is needed. [sqlite-order]\n\nB-trees do not imply row-oriented storage: Graefe's columnar design uses common logical row tags across separate trees. Its slot-derived tag compression depends on consecutive tags; gaps require additional handling. [graefe-columnar]",
  "related": [
    "secondary-index",
    "b-tree",
    "sqlite-without-rowid"
  ],
  "citations": [
    {
      "id": "innodb-indexes",
      "title": "MySQL 8.4: Clustered and Secondary Indexes",
      "url": "https://dev.mysql.com/doc/refman/8.4/en/innodb-index-types.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "pg-secondary",
      "title": "PostgreSQL 18: Index-Only Scans and Covering Indexes",
      "url": "https://www.postgresql.org/docs/18/indexes-index-only-scans.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "pg-cluster",
      "title": "PostgreSQL 18: CLUSTER, one-time ordering and locking",
      "url": "https://www.postgresql.org/docs/18/sql-cluster.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "sqlite-format",
      "title": "SQLite file format: table storage and secondary-index row locators",
      "url": "https://www.sqlite.org/fileformat.html#representation_of_sql_indices",
      "accessed": "2026-11-18"
    },
    {
      "id": "sqlite-order",
      "title": "SQLite SELECT: ORDER BY and undefined result order",
      "url": "https://www.sqlite.org/lang_select.html#orderby",
      "accessed": "2026-11-18"
    },
    {
      "id": "graefe-columnar",
      "title": "Goetz Graefe: Efficient columnar storage in B-trees, sections 1 and 3-4",
      "url": "https://sigmodrecord.org/publications/sigmodRecord/0703/03.article-graefe.pdf",
      "accessed": "2026-11-18"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-18",
  "provenance": [
    "Cross-engine source synthesis, scoped to MySQL 8.4, PostgreSQL 18 and SQLite's documented file format. No new engine execution or performance measurement."
  ]
}
