Indexes Flashcards
Describe the make up of an index
- Pages (index nodes)
- B tree structure
- With a root, intermediate and leaf levels
What are the 3 levels of an index
- Root level
- intermediate level
- leaf level
How does the query engine find a row using an index?
- Starts at root and works down hierarchy until it reaches the leaf node and the value it is looking for.
- this node either contains the whole row or a pointer to the row in which case it will need to do an additional lookup.
What is a clustered index
- An index where the whole row is stored with the indexed value in the leaf node
- Each table can have only one clustered index
What is a non-clustered index
An index where a row locator to the row is stored with the indexed value in the leaf node
What do you call an index which contains more than column?
Composite index
What is an index with no repeated values called?
Unique index
What type of index is created when a primary key is specified
By default it creates a unique clustered index on the primary key
What do you call an index which has all the columns required to return a query
A Covering index
When could you heavily index a table?
When the table is large and does not change much
When should you minimize use of indexes?
- When the table has meany insert, updates and deletes
- Very small tables where a scan might be faster
How does the uniqueness of an indexed column affect performance
-the more unique the values the better the performance
Which columns in your queries are good choices for indexes
- Columns used in joins and predicates (e.g. WHERE)
- Columns in exact match queries
What is a heap?
A table without a clustered index
How can you add non-key columns to a non-clustered index
Using the INCLUDE( ) in the CREATE statement