ADSI Notes - Diogo Lopes

Search

Search IconIcon to open search

Lecture 10 - Tuning (continued)

Last updated Mar 27, 2023

Slides

# More Tuning

# Index Tuning

Topics

# Types of Queries

  1. Point Query
1
2
3
SELECT name
FROM Employee
WHERE ssnum = 8478:
  1. Multipoint Query (Index tuning is especially usefull to reduce disk accesses on non clusteres indexes)
1
2
3
SELECT name
FROM Employee
WHERE dept = 'Information Systems';
  1. Range Query
1
2
3
4
SELECT name
FROM Employee
WHERE salary >= 40000
	AND salary < 60000;
  1. Prefix Match Query
1
2
3
SELECT *
FROM Employee
WHERE name LIKE 'Ke%';
  1. Extremal Query (in a B+ Tree you would only need to follow the rightmost path)
1
2
3
SELECT name
FROM Employee
WHERE salary = (SELECT MAX(salary) FROM Employee);
  1. Ordering Query
1
2
3
SELECT *
FROM Employee
ORDER BY salary;
  1. Grouping Query (using HASH if no index is available)
1
2
3
SELECT dept, AVG(salary)
FROM Employee
GROUP BY dept;
  1. Join Query (Prevent nested loops)
1
2
3
4
SELECT e1.ssnum
FROM Employee e1, Employee e2
WHERE e1.manager = e2.ssnum
	AND e1.salary > e2.salary;

# Index Structure

# B+ -Tree

# Hash

# Clustered vs. non-clustered indexes

Clustered index

Clustered indexes can be dense or sparse

# Benefits of a Clustered Index

# Evaluation of Clustered Indexes with Insertions
# Redundant Tables

# Benefits of Non-clustered Indexes

A non-clustered index is good if the query retrieves few records compared to the number of pages in the table

# Covering

A non-clustered index can eliminate the need to access the underlying table through covering

1
2
3
SELECT B , C
FROM R
WHERE A = 5;
1
Simply put, the covering index contains the data to be searched through include, so that the SQL query can get the required data without reaching the basic table. The composite index is to create an index on the combination of multiple columns, these columns may contain all the columns of the query, or may not contain.

# Covering/composite indexes

A non-clustered index can eliminate the need to access the underlying table through covering or composite index

1
2
3
SELECT name
FROM Employee
WHERE dept = 'Information Systems';

Drawbacks

# Composite Search Keys

To retrieve records with age =30 AND salary =4000

# Indexes on small tables

# Notes

# Optimizing workloads

# Lock and log tuning

# Log tuning

Topics

Tuning the recovery system

# Lock tuning

# Trade-off between correctness and performance

# Ideal Transaction

# Eliminate unnecessary locking

Locking is not necessary when:

PROJECT RELEVANT Use available options to suppress locking

# Sacrificing Isolation for Performance

# Transaction Chopping

Trade-off The consistency of X+Y IS NOT GUARANTEED (create money or make money disappear) BUT X>=0

# Why

# Hot Spots

Lecture 9 Tuning | Lecture 11 Tuning