Database Performance Tuning and Query Optimization (a) Week 3 1 (MO2, Chapter 11-1 to 11-2) Flashcards
Database Performance-Tuning
Concepts, and sequence.
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
Database performance tuning concepts
- 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
Performance tuning: Client and Server.
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
DBMS Architecture
Data files
All data is a database is stored in datafiles
Extends
IN DBMS Enviroment refers to the ability of data files to expand in size automatically using predefined increments
Table space or file group:
logical storage place used to group related data
Data cache or buffer cache
shared, reserved memory area that stores the most recently accessed data blocks in RAM
SQL cache or procedure cache
is a shared, resereved memory area that stores the most recently executed SQL statements
An input output request
Low level data access operation that reads or writes data to and from computer devices
Database query optimization modes, what are the two principles of the algorithms proposed for query optimization
- Optimum order to achieve the fastest execution time
- Sites to be accessed to minimize communication costs
What is the evaluation based on?
- Evaluated based on:
- Operation mode
- Timing of its optimization
What are the two ways optimization modes can be classified into?
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.
Classification based on timing of optimization?
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
Classification based on type of information used to optimize the
query
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
Database statistics?
- Measurements about database objects; provide a snapshot of
database characteristics - Number of processors used
- Processor speed
- Temporary space available
Query processing
What happens at the DBMS server end when the clients sql event is received?
1. Parsing
2Execution
3Fetching
Parsing
DBMS parses the SQL query and chooses the most efficient
access/execution plan
Execution
DBMS executes the SQL query using the chosen execution plan
Fetching
DBMS fetches the data and sends the result set back to the client
SQL Parsing phase
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
Access plans?
- 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
SQL execution phase
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
SQL fetching phase
- 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