8. Database Tuning Flashcards

1
Q

Tuning principles

  1. Think ___, fix ___
  2. ___ breaks ___ (dividing the load on over more resources)
  3. Start-up costs are ___; running costs are ___ (order data, store on cache…)
  4. Render unto server what is due ___ (depends on resources of client and server)
  5. Be prepared for ___ (increasing speed is a combination of memory, disk and computational resources)
A
  1. Think globally, fix locally
  2. Partitioning breaks bottlenecks
  3. Start-up costs are high; running costs are low
  4. Render unto server what is due unto server
  5. Be prepared for trade-offs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Normalization

A relation R is normalized if A only ___ on X and X is the ___ of R

A

Depends

Only key

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

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

A as well

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

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

A

Two or more

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

Tuning Denormalization
Sacrificing ___ for the sake of
___

A

Normalization

Performance

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

Horizontal Partitioning

Instead of partitioning by atributes, do partitions by ___ to the atributes (selections) like A < 1000 and A >= 1000

A

Conditions

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

Aggregate Maintenance

Aggregate sums, averages, total values, etc in tables (___)

A

Materialized views

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

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

A

Arithmetic
Substring
Comparisons

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

Eliminate Unneeded DISTINCT

When distinct is used with already ___ atributes (primary-keys for example)

A

Distinct

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

Nested Queries

Rewrite queries to avoid nested queries, by, for example, put FROM table1, table2

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

Query Tuning

  1. ___ usage
  2. ___ of DISTINCT
  3. ___queries
  4. Use of ___
  5. Join ___
  6. Use of ___
  7. Use of ___
A
  1. Index usage
  2. Elimination of DISTINCT
  3. Nested queries
  4. Use of temporaries
  5. Join conditions
  6. Use of HAVING
  7. Use of views
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Use of Temporaries

Avoid ___ table if not needed

A

Temporary

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

Join Conditions

Prefer join on ___ indexes, and then on ___ attributes rather than ___ (more efficient)

A

Clustered
Numerical
Strings

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

Use of HAVING
Do not use HAVING when ___ is enough
Just use it for ___ on groups

A

WHERE

aggregates

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

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

A

Inefficiently

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

Types of Queries
1- ___ query - returns one value
2- ___ query - returns multiple values
3- ___ query - returns values inside a range
4- ___ query - returns a value with the desired prefix
5- ___ query - returns max or min value
6- ___ query - returns ordered values
7 - ___ query - returns grouped values
8 - ___ query - returns joined tabled values

A
  1. Point
  2. Multipoint
  3. Range
  4. Prefix
  5. Extremal
  6. Ordering
  7. Grouping
  8. Join
17
Q

Index Structures

  • ___ sndexes
  • ___ indexes
A

B+-tree

Hash

18
Q

Clustered index
___ of the table organization
Non-clustered index
___ of the table organization

A

Dependent

Independent

19
Q

Dense index
One index per ___
Sparse Index
One index per ___
Any value v between extremes of page is inside the page
Clustered Indexes can be ___ and Non-clustered indexes must be ___

A

Record
Page
Dense or Sparse
Dense

20
Q

Covering/Composite Indexes

Indexes that use two ___or more for a specific query

A

Attributes

21
Q

Indexes on Small Tables

Use if offten have ___ updating a single record

A

multiple transactions

22
Q

Tuning the recovery system

  1. Put the log on a ___ disk to avoid seeks
  2. Delay writing updates to database disks until a ___ time (usually threshold of data)
  3. Set intervals for database ___ and ___
  4. ___ the size of large update transactions
A
  1. Separate
  2. Convenient
  3. Dumps and checkpoints
  4. Reduce
23
Q

Lock Tuning

  1. ___, reduce ___ and avoid ___
  2. Snapshot ___ (Each transaction executes against the version of the data that existed when the transaction started)
  3. Eliminate ___ Locking (one transaction or read-only transactions)
  4. Use ___ isolation levels when application allows
  5. Control the ___ of locking (rows instead of tables)
  6. ___ data definition statements (change tables, indexes, …)
  7. Circumvent Hot ___ (item assessed many times that forces several lock requests)
  8. Prefer ___ transactions to mitigate blocking
A
  1. Serialize / blocking / deadlocks
  2. Isolation
  3. Unnecessary
  4. Weaker
  5. Granularity
  6. Avoid
  7. Spots
  8. Shorter
24
Q

Threads can be used to:

  1. Manage database ___
  2. Perform ___ tasks
  3. HAve a pool of ___ threads
A
  1. Connections
  2. System
  3. Worker
25
Q

Database Buffer

Ideally, store as much as possible in ___ to avoid disk accesses

A

RAM

26
Q

RAID usage

Improves ___ performance on ___ disks

A

Read

Multiple

27
Q

Cache usage

Cache improves ___ and reduces data ___

A

Throughput

Volume

28
Q

Hardware configuration

Add memory, disks, or ___

A

Processors

29
Q

Producer-consumer hierarchy
– High-level consumers Ex ___
– Intermediate consumers/resources Ex ___
– Primary resources Ex ___

A

Aplications
Database Systems
Resources managed by the OS

30
Q

Monitoring Tools

  1. ___ Explainers
  2. ___ Monitors
  3. ___ Monitors
A
  1. Query Plan Explainers
  2. Performance Monitors
  3. Event Monitors