What would happen without an index?

Technology CommunityCategory: SQLWhat would happen without an index?
VietMX Staff asked 3 years ago
Problem

Let’s say that we want to run a query to find all the details of any employees who are named ‘Abc’? What would happen without an index?

SELECT * FROM Employee 
WHERE Employee_Name = 'Abc'

Database software would literally have to look at every single row in the Employee table to see if the Employee_Name for that row is ‘Abc’. And, because we want every row with the name ‘Abc’ inside it, we can not just stop looking once we find just one row with the name ‘Abc’, because there could be other rows with the name Abc. So, every row up until the last row must be searched – which means thousands of rows in this scenario will have to be examined by the database to find the rows with the name ‘Abc’. This is what is called a full table scan.