Database Performance Tuning and Query Optimization (a) Week 3 1 (MO2, Chapter 11-1 to 11-2) Flashcards

1
Q

Database Performance-Tuning
Concepts, and sequence.

A

One of the main functions of a database system is to provide
timely answers.
* End users interact with the DBMS through the use of queries to
generate information, using the following sequence:
1. End-user (client-end) application generates a query
2. Query is sent to the DBMS (server end)
3. DBMS (server end) executes the query
4. DBMS sends the resulting data set to the end-user
(client-end) application

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

Database performance tuning concepts

A
  • Goal of database performance is to execute queries as fast as
    possible
  • Database performance tuning: set of activities and procedures that
    reduce response time of database system
  • Fine-tuning the performance of a system requires a holistic
    approach
  • All factors must operate at optimum level with minimal bottlenecks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Performance tuning: Client and Server.

A

Client side: SQL performance tuning
* Generate SQL query that returns correct answer in least amount of
time
* Using minimum amount of resources at server
* Server side: DBMS performance tuning
* DBMS environment is configured to respond to clients’ requests as fast
as possible
* While making optimum use of existing resour

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

DBMS Architecture

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

Data files

A

All data is a database is stored in datafiles

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

Extends

A

IN DBMS Enviroment refers to the ability of data files to expand in size automatically using predefined increments

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

Table space or file group:

A

logical storage place used to group related data

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

Data cache or buffer cache

A

shared, reserved memory area that stores the most recently accessed data blocks in RAM

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

SQL cache or procedure cache

A

is a shared, resereved memory area that stores the most recently executed SQL statements

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

An input output request

A

Low level data access operation that reads or writes data to and from computer devices

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

Database query optimization modes, what are the two principles of the algorithms proposed for query optimization

A
  • Optimum order to achieve the fastest execution time
  • Sites to be accessed to minimize communication costs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the evaluation based on?

A
  • Evaluated based on:
  • Operation mode
  • Timing of its optimization
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the two ways optimization modes can be classified into?

A

Automatic query optimization: Query finds most cost efective path without user intervention
Manual query optimization: Requires optimization to be selected and scheduled by the end user.

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

Classification based on timing of optimization?

A

Static query optimization: best optimization strategy is selected when
the query is compiled by the DBMS
* Takes place at compilation time
* Dynamic query optimization: access strategy is dynamically
determined by the DBMS at run time, using the most up-to-date
information about the database
* Takes place at execution time

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

Classification based on type of information used to optimize the
query

A

Statistically based query optimization algorithm: statistics are used by
the DBMS to determine the best access strategy
* Statistical information is generated by DBMS through:
* Dynamic statistical generation mode
* Manual statistical generation mode
* Rule-based query optimization algorithm: based on a set of
user-defined rules to determine the best query access strategy

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

Database statistics?

A
  • Measurements about database objects; provide a snapshot of
    database characteristics
  • Number of processors used
  • Processor speed
  • Temporary space available
17
Q

Query processing

A

What happens at the DBMS server end when the clients sql event is received?
1. Parsing
2Execution
3Fetching

18
Q

Parsing

A

DBMS parses the SQL query and chooses the most efficient
access/execution plan

19
Q

Execution

A

DBMS executes the SQL query using the chosen execution plan

20
Q

Fetching

A

DBMS fetches the data and sends the result set back to the client

21
Q

SQL Parsing phase

A

Query is broken down into smaller units
* Original SQL query transformed into slightly different version of original
SQL code which is fully equivalent and more efficient
* Query optimizer: analyzes SQL query
* Finds most efficient way to access data

22
Q

Access plans?

A
  • Access plans: result of parsing a SQL statement; contains a
    series of steps the DBMS will use to execute the query and
    return the result set in the most efficient way
  • Access plan exists for query in SQL cache: DBMS reuses it
  • No access plan: optimizer evaluates various plans and chooses one to
    be placed in SQL cache for use
23
Q

SQL execution phase

A

All I/O operations indicated in the access plan are executed
* Locks are acquired
* Data are retrieved and placed in data cache
* Transaction management commands are processed

24
Q

SQL fetching phase

A
  • Rows of resulting query result set are returned to client
  • DBMS may use temporary table space to store temporary data
  • Database server coordinates the movement of the result set
    rows from the server cache to the client cache
25
Q

Query processing bottlenecks

A

A delay introduced in the processing of an IO operation that causes the overall system to slow down.

26
Q

What are the five components that typically cause bottlenecks

A

COU
RAM
Hard disk
Network
Application code

27
Q

Indexes

A
  • Rows of resulting query result set are returned to client
  • DBMS may use temporary table space to store temporary data
  • Database server coordinates the movement of the result set
    rows from the server cache to the client cache
28
Q

Data sparsity

A

Refers to the number of of different values a column could have.

29
Q

Give the data structures used to implement indexes

A
  • Data structures used to implement indexes:
  • Hash indexes;
  • B-tree indexes;
  • Bitmap indexes.
  • DBMS determines best type of index to use
30
Q

Hash indexes

A

Based on a ordered list of hash values. A hash algorithm is used to create a hash value from a key column. This value points to an entry in a hash table, which in turn points to the actual location is the data row.

31
Q

B-Tree index

A

ordered data structure, organized as an upside down tree. The index tree is stored seperately from the data The lower level leaves of the index tree contain pointers to the actual data row

32
Q

Bitmap index

A

Uses a bit array to represent the existance of a value or condition.

33
Q

What are the two optimizer choices?

A

Rule-based optimizer:uses preset rules and points to
determine the best approach to execute a query:
* Rules assign a “fixed cost” to each SQL operation.
* Cost-based optimizer: uses algorithms based on statistics
about objects being accessed to determine the best approach
to execute a query:
* Optimizer process adds up the processing cost, I/O costs,
and resource costs (RAM and temporary space) to
determine the total cost of a given execution plan.

34
Q

Using Hints to Affect Optimizer
Choices

A

Optimizer might not choose the best execution plan:
* Makes decisions based on existing statistics; might be old
* Might choose less-efficient decisions.
* Optimizer hints: special instructions for the optimizer.
* Embedded in the SQL command text.

35
Q

Give three optimizer hints and explain

A

ALL_ROWS Instructs the optimizer to minimize the overall execution time—that is, to minimize the time
needed to return all rows in the query result set. This hint is generally used for batch mode
processes. For example:
SELECT /*+ ALL_ROWS / *
FROM PRODUCT
WHERE P_QOH < 10;
FIRST_ROWS Instructs the optimizer to minimize the time needed to process the first set of rows—that is,
to minimize the time needed to return only the first set of rows in the query result set. This hint is
generally used for interactive mode processes. For example:
SELECT /
+ FIRST_ROWS / *
FROM PRODUCT
WHERE P_QOH < 10;
INDEX(name) Forces the optimizer to use the P_QOH_NDX index to process this query. For example:
SELECT /
+ INDEX(P_QOH_NDX) */ *
FROM PRODUCT
WHERE P_QOH < 10

36
Q

Index Selectivity

A
  • Measure of the likelihood that an index will be used in query
    processing:
  • Indexes are used when a subset of rows from a large table is
    to be selected based on a given condition.
  • Cannot always be used to improve performance.
37
Q
  • Function-based index:
A

based on a specific SQL function or
expression