[1] Implementing Indexes Flashcards

1
Q

What is a Page in TSQL?

A

A page is a 8 KB unit and belongs to a single object (e.g. table).

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

How many pages make an Extent?

A

8 (64KB).

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

What are the two types of extents and how do they differ?

A
  1. Mixed extent: when the underlying pages belong to multiple objects.
  2. Uniform extent: when the underlying pages belong to only one object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does SQL Server store pages in extents?

A

The first 8 in mixed extents and the subsequent in uniform extents.

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

What are the two other names for a Heap?

A

Balanced Tree and Clustered Table.

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

Is a Heap ordered in any way?

A

No.

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

What is an IAM and what purpose does it serve?

A

Index Allocation Mapping organises pages/extents with objects.

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

What is an IAM Page and what purpose does it serve?

A

An Index Allocation Mapping Page organises pages/extents with objects.

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

How many IAM can an object have?

A

At least one.

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

What is a Doubly Linked List and how does it work?

A

It is the structure SQL Server uses to organise large objects that have multiple IAM pages. Each page has a pointer to its decendent and antecendent.

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

How does SQL Server store data in a Heap?

A

SQL Server stores new rows anywhere in a heap: i.e. in an existing page if there is space, or a new page/extent.

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

What are the explicit and implicit ways a user can avoid data being stored in a Heap?

A

Explicit: creating a clustered index,
Implicit: primary key/ unique constraints.

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

What is the name given to the situation in which not all the pages in a heap are full?

A

Internal Fragmentation

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

How does Internal Fragmentation affect memory usage?

A

Because new rows are added to existing pages that are not full, SQL Server has less pages to read when retrieving information.

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

Is a Clustered Index the same as a Balanced Tree?

A

Yes. It begins with a single IAM and multiple pages thereafter.

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

What does SQL server do when a root page in a clustered index cannot point to all first leaf level pages?

A

It creates an intermediate level of pages which can themselves point to the first leaf level pages.

17
Q

What is a Uniquifier?

A

A Uniquifier is the name given to the process by which SQL server adds its own unique sequentially-ordered values to the repeating values of a composite key that contains columns that allows duplicates.

18
Q

What are the 3 ways a clustered index finds data?

A
  1. logical order (when required),
  2. physical order,
  3. according to order of columns in clustering key
19
Q

What is fragmentation in indexing?

A

Fragmentation occurs when SQL adds rows to leafs that are not already full. It results in a splitting of the data from its physical ordering.

20
Q

What are the two types of fragmentation possible when SQL stores data?

A

Internal fragmentation occurs when there is still space available in a page for a new row. External fragmentation occurs when, forced to maintain a logical order, SQL server forces a row between two others in a page, forcing the page to split, changing the physical order of the records.

21
Q

What are the two clauses to combat fragmentation in indexing?

A

For Internal: WITH FILLFACTOR

For External: ALTER INDEX..REORGANIZE(REBUILD)