What if you could find any piece of data instantly, no matter how big your database grows?
Why Database indexing in HLD? - Purpose & Use Cases
Imagine you have a huge phone book with thousands of names and numbers. You want to find your friend's number, but you have to flip through every single page from start to end.
Searching this way is slow and tiring. It wastes time and can lead to mistakes, especially if the book is very thick or if you need to find many numbers quickly.
Database indexing works like a quick guide or table of contents. It points you directly to the page where your friend's number is, so you don't have to look through the whole book.
SELECT * FROM contacts WHERE name = 'Alice'; -- scans entire tableCREATE INDEX idx_name ON contacts(name); SELECT * FROM contacts WHERE name = 'Alice'; -- uses index for fast lookup
It makes searching huge amounts of data fast and efficient, just like finding a name instantly in a well-organized phone book.
When you search for a product on an online store, indexing helps the website quickly show you the right items without delay.
Manual searching is slow and error-prone.
Indexing creates a shortcut to find data quickly.
It improves performance and user experience in large databases.