Database
Tuning refers to a group of activities used for homogenizing and optimizing the
performance of a database. Usually, it protrudes with query tuning but
describes the design of the database files, configuration of the databases’
environment such as CPU, operating systems, etc., and configuration of the DBMS
(Database Management System) application.
Mainly,
the database performance tuning is done to maximize the use of system resources
so that application or the system works faster and efficiently as possible.
Most systems are designed in a way that they can manage their use of system
resources. However, in order to improve their efficiency, there still exists
room for improvement which can be done by configuring the database and the DBMS
and customizing their settings.
Today,
we are going to learn some of the best practices implemented by the DBAs and
developers to improve
SQL query performance or database performance. Here
you go-
Creating Optimized Indexes
Indexing acts as a
backbone for any RDBMS (relational database management system). No index
directly impacts the functioning of a SELECT statement, while the queries will
slow down if you put an excess of indexes. The fields and their order in
indexing play a vital role during the database performance tuning. While
indexing, the most important information to consider is the number of unique
values present in a column of the table. For instance, thousands of first names
in a column might maximize specific SELECT statements but it also introduce extra
index retrieval time due to the big index pages. Therefore, it’s essential to
optimize the index to balance between the two processing times.
Pre-determine the Expected Growth
Indexes
create a negative impact on DML (INSERT, UPDATE, and DELETE) queries. When an
index is created, the data for indexed columns gets stored on the disk. When
the values in the indexed column are changed or new rows of data are inserted
into the table, the database needs to reorganize the data storage to create
room for the new rows. The reorganization of data storage can take extra troll
on DML queries. However, if you need new rows in any table on a frequent basis,
you need to specify the expected growth for an index. Also, the terminology for
the predetermined growth varies in every database.
Select Limited Data
The
less data you retrieve, the faster the query runs. Instead of filtering on the
client, add as much filters you can on the server-end. As a result, less data
will be sent on the wire and you will get results much faster. Try to eradicate
any computed or obvious columns.
Avoid Foreign Key Constraints
The term is mainly
used for ensuring data integrity. But, in turn, it affects the performance of
your database. So, if your first priority includes performance, you need to
modify the process of database performance tuning. The best example of a
database avoiding the foreign key constraints is the system tables containing
meta-data information about the user databases. However, it is seen that most
users are concerned about data integrity. In such cases, they perform the data
integrity process in the application layer and use foreign key only in
development or QA environment as an error detection feature. This method will not
affect the database performance and the data integrity is also protected.
No Indexes before Loading Data
Dropping indexes on a
table before loading a large quantity of data allows the INSERT statement to
run faster. Once the insert is completed, it can be re-indexed. You can use a
temporary table to load data when thousands of rows in an online system is being
inserted. Also, ensure that this temp table doesn’t contain any index.
these tips seem really helpful. Thanks!
ReplyDeleteTuning tools can make work a lot easier, some more than others.
ReplyDeletePeople usually make mistake with indexes, thanks for letting us know its correct use
ReplyDelete