Utilising indexes on a large database table can improve performance considerably.
Take the following example:
ExampleTable with 10,000 rows of three columns: ID, OrderID, Name
By default, the primary key (in this case ID) is indexed and any searches by ID will be fast. For example:
Select * From ExampleTable Where ID = 555
However, if you search by OrderID, SQL Server will have to search all 10,000 rows to find the data. For example:
Select * From ExampleTable Where OrderID = 999
To improve performance an index should be added to the OrderID column. This can be done using SQL Management Studio or using the CREATE INDEX query.
Keywords: slow query, table performance