8. Database Tuning Flashcards
Tuning principles
- Think ___, fix ___
- ___ breaks ___ (dividing the load on over more resources)
- Start-up costs are ___; running costs are ___ (order data, store on cache…)
- Render unto server what is due ___ (depends on resources of client and server)
- Be prepared for ___ (increasing speed is a combination of memory, disk and computational resources)
- Think globally, fix locally
- Partitioning breaks bottlenecks
- Start-up costs are high; running costs are low
- Render unto server what is due unto server
- Be prepared for trade-offs
Normalization
A relation R is normalized if A only ___ on X and X is the ___ of R
Depends
Only key
Functional dependency
Functional dependency X → A holds for
relation R, iff
- two differet record r and r’ have the same value of X and ___
A as well
Vertical Partitioning
Process of dividing a table in __ smaller tables that respect to only one object
It improves performance if only a few atributes are accessed
Two or more
Tuning Denormalization
Sacrificing ___ for the sake of
___
Normalization
Performance
Horizontal Partitioning
Instead of partitioning by atributes, do partitions by ___ to the atributes (selections) like A < 1000 and A >= 1000
Conditions
Aggregate Maintenance
Aggregate sums, averages, total values, etc in tables (___)
Materialized views
Index Usage
Many query optimizers will not use indexes in the presence of ___ expressions, ___/upper/lower expressions, numerical ___ of different types and comparisons with null
Arithmetic
Substring
Comparisons
Eliminate Unneeded DISTINCT
When distinct is used with already ___ atributes (primary-keys for example)
Distinct
Nested Queries
Rewrite queries to avoid nested queries, by, for example, put FROM table1, table2
Query Tuning
- ___ usage
- ___ of DISTINCT
- ___queries
- Use of ___
- Join ___
- Use of ___
- Use of ___
- Index usage
- Elimination of DISTINCT
- Nested queries
- Use of temporaries
- Join conditions
- Use of HAVING
- Use of views
Use of Temporaries
Avoid ___ table if not needed
Temporary
Join Conditions
Prefer join on ___ indexes, and then on ___ attributes rather than ___ (more efficient)
Clustered
Numerical
Strings
Use of HAVING
Do not use HAVING when ___ is enough
Just use it for ___ on groups
WHERE
aggregates
Use of views
Views may cause queries to execute ___
For example when we just want a simple user, but we use the view for that
Inefficiently