Hash Indexes Flashcards Preview

70-464 Certification > Hash Indexes > Flashcards

Flashcards in Hash Indexes Deck (16)
Loading flashcards...
1

Where are hash indexes used?

Memory Optimized OLTP Tables

2

What is a hash index?

An array of N buckets or slots, each one containing a pointer to a row.

3

How does a hash index work?

It uses a hash function in which given a key and the number of buckets will map the key to the corresponding bucket of the hash index.

4

How does Microsoft handle hash collisions (when a hash function returns the same for two keys)?

Using chaining with linked lists.

5

How do hash indexes handle deletes?

It sets the end timestamp of the updated row to the current time (rendering it inactive) and adds a new row at the end of the chain with the last row having the index pointer to the new row.

6

How does a hash index find a record it is searching for?

* Find bucket the record is in
* Check the first row for an end timestamp and key match
* If key match and no end timestamp, then return
* If not, go to the pointer value to look at next record
* Repeat until match is found or end is reached.

7

What is the syntax for creating a hash index?

CREATE TABLE dbo.StringTable_Hash
(
PersonID nvarchar(50) NOT NULL ,
CONSTRAINT PK_StringTable_Hash PRIMARY KEY NONCLUSTERED HASH (PersonID)
WITH (BUCKET_COUNT = 1024)
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)

8

How many buckets should you create?

Create the buckets so that the most you can have based on the number of keys fills to 80%.

9

When should you use a nonclustered index for a memory optimized table?

* Queries have an ORDER BY clause on the indexed column.
* Queries where only the leading column(s) of a multi-column index is tested.
* Queries test the indexed column by use of a WHERE clause with:
* An inequality: WHERE StatusCode != 'Done'
* A value range scan: WHERE Quantity >= 100

10

When should you use a hash index for a memory optimized table?

A hash index is preferable over a nonclustered index when queries use equality predicates, and the WHERE clause maps to all index key columns

11

If a multi-column exists and there's a selection on only one of the columns, which type of index would handle that better?

The nonclustered index. Hash index can't handle that.

As long as it is the FIRST column in the index list.

If the select has all columns in the where statement, then the hash index is better.

12

Does a memory-optimized hash handle Index Scan, retrieve all table rows.

Yes

13

Does a memory-optimized hash handle Index seek on equality predicates (=).

Yes
(Full key is required.)

14

Does a memory-optimized hash handle Index seek on inequality and range predicates
(>, =, BETWEEN).

No
(Results in an index scan.)

15

Does a memory-optimized hash handle Retrieve rows in a sort order that matches the index definition.

No

16

Does a memory-optimized hash handle Retrieve rows in a sort-order that matches the reverse of the index definition.

No