Index, Index algorithm
β DB Index
to search faster in RDMS
enhance query speed
- ππ» data search faster
- ππ» data sort faster
- ππ» data update faster
- ππ» efficient management of data
βοΈ index a column in table(save as file)
- do not need to full scan the whole table record
- search index file(B+ Tree)
- search MYI file
βοΈ when index is created on a certain column
- sort column data
- saved on seperate memory with data physical address
- save column value with physical address
key-value
βοΈ When a table is created three files are made
FRM: table architectureMYD: dataMYI: index info
ππ» disadvantages
.mdbfile size increases- difficult to change one page concurrently
- updating data, inserting or deleting record in an indexed field capability β¬οΈ
- if frequent update of data, need to rewrite index
When to use Index?
- column frequently used in
where- foreign key column
- column frequently used in
join- data range is broad, but little repetition
When not to use Index?
column with high data repetition
column with high DML
β Index algorithm
βοΈ Hash Table
- save
key-value - however, not frequently used in index
- bc hash is optimized for
= - in DB, need more
<,>
- bc hash is optimized for
βοΈ B+ Tree
This post is licensed under CC BY 4.0 by the author.