Database Index
Database Index
A lookup structure that helps a database quickly find the data it needs.
In Simple Terms
A database index is like a set of markers that helps you find the information you want in a huge pile of data right away. With these markers, the system doesn't have to check the data row by row from the very first one. It can go straight to the right spot. For example, say you want to pull up the purchases from one particular date out of a massive order history. By following the markers, you can land right on that spot.
Behind the Name
Here's the story behind the name. The word "index" goes back to a Latin word meaning "pointer," or even "forefinger," the finger you use to point at something. That's why the list at the back of a book is called an index too: it points you to where things are. A database index does the same job for data. In everyday work, people often shorten it and just say "index."
Take a Closer Look!
A database index is a lookup structure that keeps track of where data is stored, so the system can quickly find the information you're after in a huge amount of data.
Think of the index at the back of a thick book: it tells you right away where to find what you're looking for.
Without an index, the system has to check every row, from the first to the last, one by one. The more data there is, the more checks it takes, so searching this way gets slow.
A widely used type of index called a B-tree sorts and organizes the values ahead of time, then follows branches to pinpoint where the data you want is stored. Because it can find things quickly even in a huge amount of data, it's used all over the place, like when a web service searches for a member by name or sorts products by price.
There are other types that work differently, too: hash indexes, which quickly find only exact matches; full-text search indexes, which search by the words inside a text; and vector indexes, which are used for similarity search in AI.
That said, while an index makes searching faster, it also adds work: every time data is added or changed, the index has to be updated as well.
An index also takes up storage space of its own, so creating too many can slow down writes and eat into your free space. That's why the basic approach is to set up indexes only on the fields that are searched often.