Індекс бази даних
Структура для прискорення пошуку даних.
A database index works much like the index in the back of a book. Instead of scanning the entire table (a full table scan), the database uses the index to find the location of the data it needs instantly. This significantly reduces the disk I/O required for queries, at the cost of some additional storage and slower write operations.
graph LR
Center["Індекс бази даних"]:::main
Rel_hash_table["hash-table"]:::related -.-> Center
click Rel_hash_table "/terms/hash-table"
Rel_relational_database["relational-database"]:::related -.-> Center
click Rel_relational_database "/terms/relational-database"
Rel_encryption_at_rest["encryption-at-rest"]:::related -.-> Center
click Rel_encryption_at_rest "/terms/encryption-at-rest"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 Перевірка знань
🧒 Простими словами
Індекс — це як список термінів у кінці підручника. Якщо тобі треба знайти 'Наполеон', ти не читаєш усю книгу з першої сторінки. Ти відкриваєш покажчик, бачиш 'Наполеон — стор. 402' і одразу перегортаєш туди. Це економить купу часу!
🤓 Expert Deep Dive
Найчастіше використовуються B-Tree (B-дерева). Індекси прискорюють читання (SELECT), але трохи уповільнюють запис (INSERT/UPDATE), бо індекс теж треба оновлювати.