🎉Indexes 🎉

Intro 🚪

 

Indexes are special lookup tables that the database search engine can use to speed up data retrieval. 
An index is just a pointer to data in a table.


 E.g like an index in the back of a book.

Types

  • Single Column Indexes
  • Unique Indexes
  • Composite Indexes
  • Implicit Indexes

The code 💻

CREATE INDEX index_name ON table_name (column_name1, column_name2)

Advantages 👌🏻

  • Searching For Records
  • Sorting Records
  • Grouping Records
  • Maintaining a Unique Column

 

 

Disadvantages 👎🏻

  • Additional Disk space?
  • Slow Update, Insert & Delete
  • Requires constantly monitoring
  • Good understanding of DB technology

 

Tips 💡

  1. Monitor your logs for often select statement and place an index

  2. Don't create indexes on columns that change too often
     
  3. Don't create indexes on tables that have huge batch updates or inserts
     
  4. Monitor execution time of your queries

Are indexes only in RDBMS? 🤔

Non-Relational databases have indexes
Same rules apply!

Demo 🤖

Made with Slides.com