Database Tuning

The database tuning describe a group of activities used to optimize and homogenize the performance of a database. The goal of the database tuning is to maximize the use of system resources to perform work as efficiently and rapidly as possible. Most systems are designed to work efficiently, but we can improve the performance by customizing the settings and the configuration  for  the  database  and  DBMS  being  tuned.

1. Why Need Database Tuning

While the initial design of the system is developed, it is very hard to predict accurate and detailed workload information of the system. Thus, it is important to tune a database after it has been designed. The initial design is refined to obtain the best possible performance. Database tuning is critical to the success of most database-centric applications. Slow performance can negatively impact employee perceptions, which could lead to a resistance in using the applications, despite the application’s correct and enhanced functionality.

2. Types of Tuning

The actual use of the database provides a valuable information that can be used to refine the initial design. Many of the initial suppositions about the expected work load can be replaced by observed usage patterns. Some initial workload specification values may be validated and others turn out due to invalidation. Initial values about the size of data can be changed with actual values from the system catalogs. Query monitoring can reveal some unexpected problems. There is generally three types of tuning as given below.

  • Tuning the indexes
  • Tuning the conceptual schema
  • Tuning the queries.

2.1. Tuning the Indexes

The indexes that are defined initially may be refined due to many reasons. The first reason may be that some queries and updates considered important in the initial work load specification are not occurring frequently. It is also observed that some new queries and updates are now more important. Thus the initial indexes must be reviewed according to this new information.

Indexes may provide the most difficult challenge, as their haphazard use can harm as much as help database performance. The purpose of an index is to enhance the performance of select statements against a table. The definitions of indexes on tables for the purpose of assisting performance will typically slow down the database system as inserts and updates are performed. Thus, the DBA must continuously monitor DBMS performance statistics to re-evaluate the  creating  and  deletion  of indexes.

2.2. Tuning the Conceptual Schema

If it is realized during the course of database design that the current choice of relation schemas does not meet the performance objectives for the given workload with any set of physical design choices, we have to redesign the conceptual schema. The decision regarding the redesign is taken during initial design process or later on i.e., after the system is used for some time. Changing the conceptual schema requires a significant effort. Many options must be  considered while  tuning the  conceptual schema,  some of  them  are as  follows:

  • Settling for a weaker normal form : Consider any The major question is “should we decompase it into smaller relations? The answer to this question depends on the normal form a relation is. Let us assume that it is in 3NF but not in BCNF. Let us further assume, that according to the guide line that depependency preserving, lossless, join decomposition into BCNF is good, we decided to decompose it further. Now suppose that a query is very frequently asked that can be easily answered when the relation is in 3NF rather than it is in BCNF. Thus we settle for a 3NF design.
  • Denormalization : This is a technique to move from higher normal forms of database modeling to lower ones in order to speed up database It is applied during the process of deriving a physical data model from a logical form. The tables are denormalized (combined) to minimize the number of joins required to extract the desired results. Denormalization causes data duplication (redundancy), which leads to data inconsistencies  and  inconsistent enforcement  of  integrity  constraints.
  • Choice of decomposition : There are many possible choices to deal with the redundancy in any The first possibility is that accept the redundancy associated with the relation. The second possibility is to decompase the relation into more than one relation to remove the anomalies. This decomposition depends upon the functional dependency and the type of queries that are applied on the relation. The decomposition may be lossless—join decomposition with no dependency preserving or dependency preserving.
  • Vertical decomposition : When a relation is to be decomposed, we have to consider which queries the decomposition affects the This factor is more important when the motivation is the improved performance. Thus if the queries are such that we have to partition the relation into more than one relation that have minimum attributes in common, the decomposition is the vertical one.
  • Horizontal decomposition : Sometimes, we have a situation such that we have to replace a relation with two relations that have the same attributes as the original relation, but each containing a subset of the tuples in the This type of decomposition is called horizontal decomposition.

2.3. Tuning Queries and Views

If it is noticed, that a query is running slower than the expected, it is required to examine the query to find the problem. The problem can be fixed by rewriting the query and tuning the index (if necessary). Tuning is also necessary if queries on some views are running slowly than the  expected time.  The different  ways to  tune the  queries are  as follows:

  1. To tune a query, first understand the plan that is used by the DBMS to evaluate the Many systems provide the facility to identify the plan. Once the plan is understood, it is possible to improve the performance. Choose different indexes or co-clustering two relations  for  join  queries.
  2. Rewrite the query to avoid some expensive operations like DISTINCT in the SELECT clause.
  3. Rewrite complex queries in steps, using temporary relations or without temporary relations.
  4. Nested queries are inefficient. So, rewrite a nested query without nesting and correlated query without  correlation.

Source: Gupta Satinder Bal, Mittal Aditya (2017), Introduction to Basic Database Management System, 2nd Edition-University Science Press (2017)

Leave a Reply

Your email address will not be published. Required fields are marked *