How does an index improve performance?
Because an index is basically a data structure that is used to store column values,
looking up those values becomes much faster. And, if an index is using the most
commonly used data structure type – a B- tree – then the data structure is also
sorted. Having the column values be sorted can be a major performance
enhancement – read on to find out why.
Let’s say that we create a B- tree index on the Employee_Name column This means
that when we search for employees named “Jesus” using the SQL we showed earlier,
then the entire Employee table does not have to be searched to find employees named
“Jesus”. Instead, the database will use the index to find employees named Jesus,
because the index will presumably be sorted alphabetically by the Employee’s name.
And, because it is sorted, it means searching for a name is a lot faster because all
names starting with a “J” will be right next to each other in the index! It’s also
important to note that the index also stores pointers to the table row so that other
column values can be retrieved – read on for more details on that.