Monthly Archives: October, 2018

ericvanier.com Database Tuning

13: Techniques for Database Optimization in MySQL

Posted by MySQL NEWS No Comment yet

Database lays the foundation for any kind of online operations. As the entire data flow into the system from the database, having a high database performance is important. It is thereby often recommended to opt for Database Optimization for the high performance of the database.

Diligent Database Administrators perform database tuning on a regular basis to keep up the performance of the database. But before we jump on to the MySQL Database optimization techniques, let us first understand what Database Optimization means.

What is Database Optimization?

Database Optimization refers to the techniques used in order to ensure the fastest possible time in which the SQL queries run for a database, resulting in a higher productivity. These techniques involve foreseeing different aspects to ensure an overall good health of the database.

Why is it important to perform Database tuning regularly?

A regular database tuning ensures a faster database access speed. This is done by finding all the possible areas of a slowdown by regular checkups. At the same time, queries are optimized to ensure they run fast and give the desired output.

 

For smaller databases where the data populated remains considerably less, the time difference between upon running a tuned database and any other database is not significant. But, when the databases are considerably large, then the time lapse between a tuned and an untuned database is significant, making regular database tuning important for overall seamless operations.

Techniques to perform Database tuning in MySQL

Here’s how you can optimize your database for a high performance by using the following MySQL database optimization techniques:

1.   Perform regular server health check-ups

Mysql Database optimization techniques

Server forms the spine of any database, and to keep it in good health, it is important to perform regular health check-ups. This would help you in detecting and rectifying areas causing a slowdown.

You can use tools for database tuning such as Execution Related Dynamic Management Views and Functions (Transact-SQL), which are commonly known as DMVs, to detect slowdowns by checking server health upon execution.

2.   Create optimized Indexes to make queries efficient

Creating efficient and well-optimized indexes is one of the most effective ways of database tuning in MySQL. A well-optimized index, allows a query to avoid unnecessary scanning of the entire tables for the result. This is very beneficial especially when the size of the database is quite large.

SQL server automatically measures and stores the statistical information of the distribution of values in the Indexed column as soon as the Index is created. This information helps in formulating the best optimizing strategy for the database.

 

3.   Create optimized Select queries

SELECT * (Select All) query often requires much more processing than other Select queries. Thus, it is always advised in order to use specific fields to make the processing lot faster for database tuning.

Also in the case where you want a fixed number of results, you can use LIMIT to get the required number of results and avoid unnecessary processing of the entire database.

These optimized Queries help a lot in database tuning by increasing performance, especially when the size of the database is large.

4.   Avoid using Nested loops in queries

Nested loops in the queries cause slowdown, especially when the data to be processed is large. Since there could not be parallel processing in the nested loops and they access the data only one after the other, it makes the process lengthier.

For database optimization in MySQL, try to avoid nesting loops while structuring queries.

5.   Analyze real-time statistics regularly

ericvanier.com Database Optimization

For database tuning, it is important to monitor and keep a track on the real-time statistics of the database by using different MySQL database optimization techniques and tools such as Live Query Statistics.

 Live Query Statistics, is very substantial for debugging SQL query performance related issues in real-time, as it displays statistics of step by step query execution. This helps in closely understanding and detecting which steps are causing slowdown by analyzing.

What makes this tool a pro is the statistics are available when the query is still executing, helping the Database administrator to understand and tweak queries where it is required for database tuning to boost the performance.

 

The next step

While the above MySQL optimization techniques will help you in database tuning, but you need to make sure you practice these basic techniques on a regular basis to ensure an optimized performance of your database.

If you require any further assistance in database performance related issues or an expert consultation, then you feel free to contact me, to help you overcome the challenges.

ericvanier.com database consultant

12: Top 5 Skills of a Database Consultant

Posted by MySQL NEWS No Comment yet

Big Data has taken over the world by storm. And with focus narrowing to the ever-increasing amount of data, database consultants are more important than ever. Hence, there is an influx of job opportunities for database consultants.

But, with organizations looking out for database professionals, it is very important to understand the right set of skills for a qualified and efficient database consultant. Most of the functions of a Database Administrator are technical in nature. However, there is a set of skills that differentiate the good from the best. Today we look at the top five unique skills of a database consultant and understand their importance in the industry.

Problem Solving abilities

The most basic qualification for any database consultant is the ability to tackle complex problems. Now with such a vast amount of data, it is very important to recognize the patterns being formed. A good database consultant, with problem skills, will not only be able to understand the patterns but also create algorithms and process flows to optimize the output.

While technology has advanced over the years, it is very important to have a human intervention for problem-solving. This human intervention will further reduce any errors and ensure an efficient working of the database.

Data Visualization

ericvanier.com database consultant visualization
For a database consultant, it is very important to understand the data and create a visual representation of the same. This representation consists of charts, graphs and flows charts. But simple visualization lacks innovation and clarity. A quality of a good DBA is the ability to tell stories through the data.

In the modern day, stories are an essential part of our life. Scrolling through the internet or magazines, stories are the easiest way to communicate. This storytelling through data influences the ways products are created and work. An organization looking for a good database consultant should look for an individual who can inspire the User interface as well as the User experience of the product based on data.

Clear communication

While technical qualifications and a sound understanding of the industry are a must for any database consultant, it is equally important to have a set of soft skills as well. Communication is the key to any successful venture.

When it comes to database management, communication with the client is very important. This isn’t necessarily presentations and Excel sheets but a display of the output. This involves understanding the customer’s needs and presenting it accordingly. A website framework presented on a localhost preview will have a better impact than a PPT. But, it is the key skill of a database consultant to identify these methods and communicate effectively.

Managerial Capabilities

Managing a project is one of the most important skills for any industry. Even for database management, project management plays an important role. Organizations looking for a good database consultant should look out for some key management qualities as a skillset.

Not every individual is capable of all the technical aspects. This means work needs to be divided as per skillsets and capabilities. As a good database consultant, it is necessary to manage both the product as well as the client. Hence, management is a key skill that an organization should seek when looking for a database consultant.

The Hardware/ Software understanding

 ericvanier.com database consultant hardware

Database management is a combination of high-end hardware and software. As the amount of data increases, the requirements increase too. Common issues with data often arise and these are highly dependent on the hardware such as storage devices. The hardware is powered by compatible software.

An understanding of this combination is essential to a successful execution. As a database consultant, it is important to know the why and the how. So understanding how the system works both on the inside and the outside is what makes a perfect database consultant.

So, for any organization looking at a database consultant to take control of their database management system, the above-mentioned skills can help them find the perfect match. Moreover, a combination of all these will lead to an efficient and optimized working.

ericvanier.com SQL Performance Tuning

11: Getting Started with SQL Performance Tuning

Posted by MySQL NEWS No Comment yet

Sometimes you might have faced the issues of slow SQL performance due to some queries. This slowdown might have also impacted your operations to a major extent. And every time you might have felt the need to improve the performance of your SQL database. Well, you can easily improve the performance of your SQL database by tuning it.

 

What is SQL Performance Tuning?

SQL performance tuning, are several techniques used to ensure that the queries of the SQL database run in the fastest possible span to give maximum productivity.

 

Why is SQL Performance Tuning important?

While the smaller databases might not find SQL tuning significant, but when the databases are very huge ranging up to some Terabytes (TBs), then SQL performance tuning plays a major role in cutting down the query runtime resulting in a much-improved efficiency, making operations a lot faster than before.

Thus, for better performing fast operations, SQL performance tuning of databases is important.

 

How to do SQL Performance Tuning?

Here are a few ways you can use for doing SQL performance tuning of your database to it speed up:

  • Ensure a database server health check-up using DMVs

Use DMVs (Dynamic Management Views), to ensure server health and find the areas of slowdown. It gives the analytics and information about the active sessions and connections, letting you know the objects which consume most memory causing a slowdown.

 

You can use the below query to know the memory consumption of the given object, to identify areas of slowdown.

 

Select * from $System.discover_object_memory_usage

 

  • Avoid using SELECT * instead use SELECT fields

Using SELECT * (Select All) means calling of all the available data in the given database, which is often a stringent and more time-consuming process, often calling fields which are actually not required. Thereby, causing inefficiency and consuming more time.

 

If you use SELECT fields query that would mean you call only the required fields. This helps in significant optimization especially when the databases have a large number of rows and fields.

 

Avoid

SELECT *
FROM Users

 

Instead, use

SELECT FirstName, LastName, Address, City, State, Zip
FROM Users

 

  • Avoid using SELECT DISTINCT instead use SELECT for more fields

If you are using SELECT DISTINCT for removing duplicate queries, a lot of processing is required to call the query. As the SELECT DISTINCT query GROUPs all fields to create distinct results, it requires more processing time and can cause a slowdown when the database is significantly large.

 

Instead, if you opt to remove duplicate fields by calling SELECT for more fields, you tend to get unduplicated records without much processing, optimizing your database performance.

 

Avoid

SELECT DISTINCT FirstName, LastName, State
FROM Users

 

Instead, use

SELECT FirstName, LastName, Address, City, State, Zip
FROM Users

 

  • Prefer using Parameterized Queries

Using Parameterized Queries can improve the performance of the database, as they compile the query only once while executing the compiled plan multiple times. This can save time for recompiling each time, thereby improving performance.

 

Prefer

SELECT “User ID” FROM User WHERE “Sales ID” = ?

 

  • Prefer INNER JOIN to create joins over WHERE

Using WHERE to create joins result in a Cartesian of CROSS JOIN, where all the possible combinations of variables are created, causing a lot of unnecessary processing. This impacts more especially when the number of variables is more, like that in bigger databases.

 

While using INNER JOIN can be used to optimize the query as it does not create a Cartesian join.

Avoid

SELECT Users.UserID, Users.Name, Sales.LastSaleDate
FROM Users, Sales
WHERE Users.UserID = Sales.UserID4

 

Instead, use

SELECT Users.UserID, Users.Name, Sales.LastSaleDate
FROM Users
INNER JOIN Sales
ON Users.UserID = Sales.UserID

 

 

  • Prefer using LIMIT for sample queries

You can limit the number of results when using sample queries. Using LIMIT will run only the given number of outcomes, instead of calling the complete data.

 

Prefer

SELECT FirstName, LastName, Address, City, State, Zip
FROM Users

LIMIT 20

 

The Bottom Line

SQL Performance Tuning is very helpful in optimizing database performance significantly by decreasing the processing time, especially for large databases, improving overall efficiency.

If you are stuck with performance improvement, get in touch with me. I will help you unlock the true performance of your database.