Week 2 - Major Indexing Schemes Flashcards
Hash Indexes what is it good for ?
1) Hash-based indexes are good for equality selections
(age =16, id=2)
2) takes keys and puts data in data bucket
What kind of indexing scheme should be used in order to retrieve data on customers whose zip code is equal to 06902?
1) Equality index
2) Clustered index
3) Heap-based index1
4) Hash-based index
4) Hash-based index
Index entries have what
Have pointers to where that data is.
So, the index entries help you just navigate,
so it help you search,
and the data entries are the last level where you go ahead, and retrieve the data from where it’s stored in the database.
Ways to store data entries
1) key (record ID)
2) Key (list of record IDs)
We know that data is stored in the form of records. Every record has a?
key field
An ______ is a data structure that locates these key fields within the database file
index
What is a clustered index
Data records are sorted like the data is sorted. Stored by the attribute (like an id)
un-clustered index
The record is not sorted by the data.
Note same sorting order
What type of index should you use?
Depends on workload
Where should you put the index if all the queries access the same attribute
1) The index should be on that attribute (what is in the WHERE )
2) how what percentage of the data is selected Lower the better
IF the query selects 95% of data is that a good place to put and index
No
Lower is better (more refined)
Cost of Indexes
1) storage (hard disk space)
2) If there are lots of inserts can be slower
3) Maintain index (hard if updating it a lot)
If a database has m rows and n columns, what is the maximum number of clustered indexes for this table?
1) 1
2) n
3) mn
4) m
1) 1
A database table can only have one clustered index.
Four considerations for creating a new index
1) Consider the most important queries
2) Consider the best plan using the current indexes
3) Determine if a better plan is possible with an additional index
4) How often the index needs to be updated
4 Index selection Guidelines
1) Attribute in the WHERE clause
2) Keys (primary, unique attribute)
3) Searches on multiple attribute
4) If index will benefit multiple queries