Skip to content

Order of Indexing Matters

In SQL Server, the order that you declare Indexes matters! So take the following example:

And we run this query:

SELECT  cast(ca.AreaID AS varchar(4)),
        RemovalDate
FROM    ContentAreas ca WITH ( NOLOCK )
WHERE   ContentID = 232232
        AND removerID = 34343

If you are to run the following query, since you are using ContentID as part of the WHERE clause, you want to put the ContentID’s index at the top of the indexes/key in SSMS. It speeds up retrieval.  Also put RemoverID below that – test with viewing the execution plan first to see if it makes a difference. Remember, the more indexes you add, the more it takes to update the index.

Categories

SQL Server

Dan View All

Blog owner.

%d bloggers like this: