Post

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 architecture
  • MYD: data
  • MYI: index info

πŸ‘ŽπŸ» disadvantages

  • .mdb file 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 <, >

βœ”οΈ B+ Tree

This post is licensed under CC BY 4.0 by the author.