Posts tagged " MySQL Management "

Step by Step Advanced MySQL Query Tuning

#4: MySQL SQL Query Optimization and Database Tuning for Beginners

Posted by MySQL NEWS No Comment yet

MySQL SQL Query Optimization and Database Tuning for Beginners

It is not easy to find highly optimized SQL queries and well-structured databases. You might have the task to design a DB or to improve the performance of queries, either way, you need to be prepared to handle the challenges. MySQL SQL Query Optimization and database tuning are important skills that will help you make the application perform better.

In this article, we will go through what these tuning and optimization techniques mean. I will demonstrate some basic examples. The scope of this article is for beginners, but towards the end, we will talk about how to learn other skills such as advanced MySQL query tuning.


What is SQL Query Optimization

Step by Step Advanced MySQL Query Tuning

Step by Step Advanced MySQL Query Tuning

Query optimization in DBMS  or query tuning is the process of altering the query to make it run faster. Often, the queries which are initially written aren’t designed for scale. This leads to the query slowing down the application as the amount of data increases.

As a beginner, you must understand some of the basic concepts behind an SQL query. This will help you identify potential problems with queries that you are tuning. Following are some of the SQL Optimization Techniques:


  1. The very first technique is to check the select statement. Very often, developers tend to use the “*” in a select query.




What you must understand here is that the “*” should be used only when all the fields need to be fetched.To make the query faster, mention only the fields that need to be fetched. Example:



  1. Using the operators IN, EXISTS appropriately. You must understand when each of them has to be used. It has been found that using “IN” is the slowest when it comes to query execution time. Following is an example of how you can perform SQL query optimization when you find a query having the IN operator.




            Now, instead of the above query, you can use EXISTS as follows.




            WHERE M.EMP_ID = E.EMP_ID)


  1. You can also use simple MySQL query optimization tools like the “EXPLAIN” operator. This operator, when added to the beginning of a query, gives you a sense of time the query will take to execute. It might not be fully accurate, but as a beginner, this will be very useful to you. The output of this query is called “QUERY PLAIN”. Following is an example:



            WHERE SALARY> 100000;


This will give you a cost associated with the query and higher the cost indicates, longer run time.


What is Database tuning


There are many things which overlap Database tuning and SQL query optimization. These two concepts are interrelated. However, the database tuning refers to the way in which database needs to be designed, and how to choose the right DBMS application and how to best set up the DB environment. Though this skill comes with time and experience, there are a few things you can look out for that would make your database more efficient.


  • The very first thing you do is Normalize the database. Database Normalization is the process of removing redundant columns or to restructure the tables. Normalization helps to decrease anomalies that tend to occur when various queries are executed. The normalization process is divided into 4 different forms each addressing the various ways in which redundant data can be identified and used.


  • Creation of optimized indexes. Index creation is a tricky subject. No indexes will lead to queries being slow and too many indexes will slow down the DML queries ( queries to insert, update and delete). This means that indexes must be created only when it is required. In my upcoming webinar series: “Advanced MySQL query tuning”, I take you through each task of SQL query optimization step by step. Enrolling in the course gives you a lot of benefits that can boost you to the next level.


  • DB statistics tools provide information on table indexes and their distribution. These statistics help the DBA to find paths that not only satisfy a query but is also inexpensive.


Conclusion: what to do next?


We saw how you can quickly identify some of the most common mistakes developers or DBAs make. You can identify such anomalies and correct them to improve the database performance.


These, however, were just the basics. A drop in the ocean. As a DBA or someone performing SQL Query Optimization or Database tuning, there is much more to learn and apply. Over the 17 years in the industry, many of the Fortune 500 companies have hired me as a performance expert consultant and I have successfully helped them in overcoming their challenges.


MySQL Optimization

#3: Top 3 must have MySQL DBA skills for 2017

Posted by MySQL NEWS No Comment yet

Top 3 must have MySQL DBA skills for 2017

Database administrators are faced with the rapid advancements in database technologies. There are new updates, features or releases that are rolled out frequently. This makes it important to make sure that your DBA skills are up to date. I have worked closely with some of the fortune 500 companies as a database consultant and a DB performance expert. In this article, I share with you the top DBA skills that you must have to become a better DBA.

Why is it necessary to improve your DBA skills?


As of today, DBAs are faced with many key challenges. These challenges involve a paradigm shift in the way applications are developed, turning all the focus to them. The fact still remains that at the heart of it lies the database.


A few years ago, having MySQL DBA skills or even more specific like the Oracle DBA skills were considered sufficient. But now with the advancement of technologies like NoSQL, a DBA is faced with the challenge of being an expert with these newer technologies.


The graph below is the result of a study made by Gleanster Research. The graph indicates the most common reasons for performance issues in applications. As you can see, database related issues are number one with it occurring 88% of the time. Being a database Performance Expert, I have helped many organizations to solve their issues and improve the overall performance.


MySQL Performance

MySQL Performance


Let us now walk through the top DBA skills required for 2017.


1.Managing Distributed Database systems

Managing Distributed Database systems

Managing Distributed Database systems


With the advancement in cloud computing and cloud data storage, most of the applications are built with distributed databases. An organization’s critical data might be present on the “on-premise data center” . However, the remaining majority amount of data might be present in the cloud. This makes it very important for DBAs to have the knowledge on distributed data systems and its implications on the application’s performance.


When it comes to distributed data systems, knowing what has to be done where is the most valuable skill among all the DBA skills. Following are some challenges that you have to be ready to face and how you can optimize.


  1. When there is a choice of deployment between on-premise and cloud, the performance implications due to latency and bottlenecks should be considered.
  2. Deployment of distributed systems can become unpredictable due to factors like backup load time, internet speed, etc, and to mitigate these factors, consistency must be maintained while using the deployment tools or software and strategies.
  3. There is a chance of problems not being solved only by moving databases to the cloud. In such cases, the inherent performance issues must be taken into consideration.
  4. Moving to the cloud will have a security risk attached to it. This requires you to move beyond the traditional encryption based security service and provide a much more secure platform.
  5. The backup, recovery and restoring strategies must be thought of thoroughly as distributed systems can cause issues only in certain places.

2. Adapting to the shift in development approaches


From the research that I have stated earlier, DBs are one of the major reasons for performance issues. They are the heart of almost every application. With organizations relying heavily on applications to run their business, the focus is shifting to building better applications. When a shift like this occurs, the DBA no longer is responsible for just the database.


The responsibility increases to the whole application. This does not mean that the DBA should know application development. What it means is that the DBA needs to make sure that the application performance is not compromised due to database related implications. The required DBA skills, in this case, would be as follows.


  1. The DBA must maintain a performance trend of the application over time. This trend will contain in detail the performance measure of the application over days, weeks, and months. This would then form a tool for identifying patterns, or anomalies in application performance which intern might be related to issues in the database.


  1. The resources that are allocated to the DBs come under the umbrella of traditional SQL DBA skills. But, with the shift in approach, the DBA must move a step further and be accountable for the application as a whole. This can be done by managing and maintaining the logs of end-user wait times. Keeping a tab on what the end-user is waiting on and what kind of data is affecting the load time is important. This information can be used to tune the DBs to improve performance.
  2. The DBA must explore and set up all the necessary tools for monitoring not just the state of the DB servers, but also the other infrastructures like storage machines, hosts, networks, etc. Without this, it can get extremely difficult to perform any check on the application while monitoring for errors and anomalies.


3. Diversification of Database platforms


Diversification of Database platforms

Diversification of Database platforms


The applications are no longer always monolithic. As of now, applications are typically broken down into manageable sub units each having an architecture that suits the type of data it consumes. When situations arise where these units consume unstructured data, No-SQL databases like Mongodb or Cassandra are used. This makes it important for the DBAs to adapt to newer Databases and know how to manage all the different databases efficiently. Following are some of the DBA skills with respect to multiple databases.


  1. Evaluating the cost and performance measures with regard to moving various databases to the cloud vs keeping it on-premise. As a DBA, you will have to assess the performance parameters before moving a particular database to the cloud or moving it away from cloud to a local data center.


  1. Just like the other skills, you should find a single point tool for all the different databases. Maintaining a different dashboard for each type of database will make it cumbersome to manage them. A better solution would be to invest on a software that provides a single dashboard for all the different types of databases.


  1. As much as possible try to maintain consistency when it comes to integrity and security of the data. Also, use consistent strategies for backup and restore. This will make sure that the failure due to mixing up of strategies reduces, thereby improving the capability of the database.




With this, I hope you are ready to transform, adapt, and embrace the challenges that a DBA encounters. With the change in trends, we must adapt to those changes so as to remain in the game and become better at it.

I have designed and created a series of webinars which aims to help DBAs like yourself to become better and stay up to date with the technology. I have shared the knowledge I have gained through my experience in the industry  and I can assure you that you will have many things you can take away from it.