Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the different types of indexes, what are the benefits of each?

What are the different types of indexes, what are the benefits of each?

I heard of covering and clustered indexes, are there more? Where would you use them?

like image 861
Brian G Avatar asked Sep 25 '08 20:09

Brian G


People also ask

What are indexes in database and what are benefits of using indexes?

Indexes are used to quickly locate data without having to search every row in a database table every time a database table is accessed. Indexes can be created using one or more columns of a database table, providing the basis for both rapid random lookups and efficient access of ordered records.

What are some different types of indexes in SQL?

There are two types of Indexes in SQL Server: Clustered Index. Non-Clustered Index.

What is the benefit of using an index?

An index gives a quick measure of the state of a market. Index funds are a low-cost way to invest, provide better returns than most fund managers, and help investors to achieve their goals more consistently.


2 Answers

  • Unique - Guarantees unique values for the column(or set of columns) included in the index
  • Covering - Includes all of the columns that are used in a particular query (or set of queries), allowing the database to use only the index and not actually have to look at the table data to retrieve the results
  • Clustered - This is way in which the actual data is ordered on the disk, which means if a query uses the clustered index for looking up the values, it does not have to take the additional step of looking up the actual table row for any data not included in the index.
like image 116
Chris Shaffer Avatar answered Oct 05 '22 23:10

Chris Shaffer


OdeToCode has a good article covering the basic differences

As it says in the article:

Proper indexes are crucial for good performance in large databases. Sometimes you can make up for a poorly written query with a good index, but it can be hard to make up for poor indexing with even the best queries.

Quite true, too... If you're just starting out with it, I'd focus on clustered and composite indexes, since they'll probably be what you use the most.

like image 33
Kevin Fairchild Avatar answered Oct 06 '22 01:10

Kevin Fairchild