> For the complete documentation index, see [llms.txt](https://gunkim.gitbook.io/undefined/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gunkim.gitbook.io/undefined/mysql-clustered-index.md).

# MySQL 클러스터링 인덱스 (Clustered Index)

## 개념

* **Index-Organized Table (IOT)**: 프라이머리 키(PK)를 기준으로 테이블의 실제 데이터(Row)가 물리적으로 정렬되어 저장되는 구조.
* 비유하자면 알파벳 순서로 인쇄된 **영어 사전**과 같음. 단어(PK)와 설명(실제 데이터)이 함께 정렬된 상태.

## 핵심 구조

* \*\*B+Tree의 리프 노드(Leaf Node)\*\*가 실제 데이터 행 전체를 품고 있음.
* 일반적인 힙(Heap) 테이블처럼 데이터를 들어오는 순서대로 무작위로 쌓는 것과 대비됨.

## 장점 및 특징

* **압도적인 검색 속도**: PK 기반의 검색이 매우 빠름.
* **물리적 정렬**: 범위 검색(Range Scan)에 유리함.

## 트레이드오프 및 한계

* 데이터 중간에 새로운 PK가 끼어들거나 변경되면, 그 위치를 맞추기 위해 기존 데이터들의 물리적인 위치가 뒤로 밀려나는 **페이지 스플릿(Page Split)** 비용이 발생함.
* 따라서 무작위 PK(UUID 등)보다는 순차적으로 증가하는 값(Auto Increment)을 PK로 쓰는 것이 권장됨.

## 오답 및 주의사항

> \[!WARNING] 클러스터링 인덱스에서는 데이터(Row) 자체가 B-Tree의 구조 안에 속박되어 있다. "인덱스와 데이터가 별도로 존재한다"고 착각하면 안 됨.

## 관련 개념

* \[\[mysql-secondary-index]]
* \[\[b-tree]]


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gunkim.gitbook.io/undefined/mysql-clustered-index.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
