✅ Yes — a Composite Index is usually a B-tree index too.
Let’s clarify:
📘 Composite Index vs. B-tree:
- B-tree is the data structure used to implement the index.
- Composite index refers to the fact that the index is built over multiple columns, like
(A, B, C)
.
So:
A composite index is just a B-tree that stores tuples of multiple columns.
🔍 Example:
CREATE INDEX idx_name_email ON Users(name, email);
This creates a B-tree index ordered like:
(name, email)
That means it’s sorted first by name
, and within that, by email
.
✅ So it’s both:
- A composite index (multi-column)
- Implemented as a B-tree
🧠 Analogy:
Think of a composite B-tree index as a multi-key phonebook:
- First sorted by last name
- Then by first name
- Then by city
You can search:
- All Smiths ✅
- All “John Smiths” ✅
- Just “people from Chicago”? ❌ (not helpful unless city is the first column)
✅ Summary:
Term | What it means |
---|---|
B-tree Index | Index structure used by most RDBMS |
Composite Index | B-tree over multiple columns |
You nailed it — the confusion is often in naming, but technically, composite ≠ different type, it’s just a B-tree with multiple fields.