The classic analogy for SQL indexes goes … Databases are like libraries.<\/p>\n\n\n\n
Tables are like books stored in a library.<\/p>\n\n\n\n
Rows are stored on pages of a book.<\/p>\n\n\n\n
Flipping through a textbook page by page looking for that one page you need is going to take time. The same way scanning millions of rows is going be time-consuming and tedious. That’s where SQL indexes come in.<\/p>\n\n\n\n
Why do I need an index?<\/a>
Are there different types of indexes?<\/a>
Where can I find my index once it’s created?<\/a>
What are good candidates for indexes?<\/a>
Can’t I do this later?<\/a>
Do I need to do this at all?<\/a>
How many indexes are too many?<\/a>
Is this the answer to all my performance problems?<\/a><\/strong><\/p><\/blockquote>\n\n\n\n
\n\n\n\nWhy do I need an index?<\/h2>\n\n\n\n
Indexes speed up performance by either ordering the data on disk so it’s quicker to find your result or telling the SQL engine where to go to find your data. If you don’t apply an index, the SQL engine will scan through every row one by one.<\/p>\n\n\n\n
While this isn’t necessarily a bad thing, as your database grows things could start to slow down.<\/p>\n\n\n\n
\n\n\n\nAre there different types of indexes?<\/h2>\n\n\n\n
There are two main types in SQL Server:<\/p>\n\n\n\n
Clustered Index – the contents page<\/h4>\n\n\n\n
Physically arranges the data on disk in a way that makes it faster to get to.<\/p>\n\n\n\n
You can only apply one per table because the data can only be ordered one way.<\/p>\n\n\n\n