Indexes Flashcards

1
Q

Describe the make up of an index

A
  • Pages (index nodes)
  • B tree structure
  • With a root, intermediate and leaf levels
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 3 levels of an index

A
  • Root level
  • intermediate level
  • leaf level
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does the query engine find a row using an index?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a clustered index

A
  • An index where the whole row is stored with the indexed value in the leaf node
  • Each table can have only one clustered index
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a non-clustered index

A

An index where a row locator to the row is stored with the indexed value in the leaf node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do you call an index which contains more than column?

A

Composite index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an index with no repeated values called?

A

Unique index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of index is created when a primary key is specified

A

By default it creates a unique clustered index on the primary key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do you call an index which has all the columns required to return a query

A

A Covering index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When could you heavily index a table?

A

When the table is large and does not change much

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When should you minimize use of indexes?

A
  • When the table has meany insert, updates and deletes

- Very small tables where a scan might be faster

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does the uniqueness of an indexed column affect performance

A

-the more unique the values the better the performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which columns in your queries are good choices for indexes

A
  • Columns used in joins and predicates (e.g. WHERE)

- Columns in exact match queries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a heap?

A

A table without a clustered index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you add non-key columns to a non-clustered index

A

Using the INCLUDE( ) in the CREATE statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does a clustered index and column store index differ in the way the table data is stored

A

The tables are stored in rows on the leaf nodes of a column store index
The each column in table is stored in its own segment and highly compressed

17
Q

Give 3 advantages of column store indexes over clustered indexes

A
  • When a row store index is used even if only one column is being returned the whole row is loaded into memory rather than just one segment.
  • Because each segment has the same data type it can be heavily indexed which means even more data can be brought into memory
  • Batch processing mode can operate on batches rather than row by row
18
Q

What is a dictionary used for in a column store index

A
  • It can be used with string columns or those with few distinct values to create a lookup.
  • A reference is stored in column store rather than the value which saves even space