In this article we'll discuss the impact of excessive MySQL activity, and how it can be detrimental to your account's overall resource usage. MySQL is the database back-end of many popular web applications and it's where those applications store their data to later be retrieved by server-side scripts to pull that information into your pages.

If you happened to have received a notice from our system administration department regarding excessive MySQL activity coming from your account, then more than likely this means that the level of activity they were seeing exceeded the capabilities of the hosting platform your account currently resides on.

Common causes of excessive MySQL activity

Long running queries A typical SQL query should be able to complete within 1 second to maybe a few seconds at most. Having long running queries that consistently exceed these query times can lead to delays in serving other queries on the server.
High queries per second Typically SQL queries will come in small waves in direct proportion to your traffic, and if your scripts are requiring a large amount of SQL queries per page load, then you could potentially have a high number of SQL queries per second which can lead to a negative impact on the server's query performance and start leading to long running queries.
Large queries not optimized Some SQL queries will be very complex in nature, especially ones that join together multiple tables of data before performing operations on that data. Ensuring that your SQL queries are efficient and only pulling up the data they actually need to display, can help stop those inefficient queries from causing either long running queries, or a high number of queries per second.
Persistent connections Most SQL queries will simply open a connection to the database, retrieve data, and then close the database connection. MySQL also does support persistent connections where the connection is maintained even after the data is retrieved. This can sometimes be problematic especially on shared hosting where you could run into the max_user_connections limit set in MySQL.

In most cases if your MySQL activity is excessive our system administration department will contact you with a general explanation on where the activity seems to be coming from.

Optimizing MySQL usage

A good first step at optimizing your MySQL database is by using phpMyAdmin to optimize a database.

Sometimes your normal MySQL activity could be perfectly fine but when robots start to crawl your site this could highlight inefficiencies in your application, so also knowing how to stop search engines and robots from crawling your website would be good information to know as well.

Finally you'd also want to look at the SQL caching options available to your application. For example if your front page requires 2 SQL queries to display all the information on that page, and you have 100 people come to that page, that's going to be 200 queries and it's not pulling back any unique data just the same stuff every time.

Implementing SQL caching can help cut down on these duplicate database queries, for an example of this type of caching you can read about optimizing WordPress with the W3 Total Cache plugin.

 

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

News / Announcements

WordPress wp-login.php brute force attack
Updated 2014-07-17 06:43 pm EST
Hits: 200883

Related Questions

Here are a few questions related to this article that our customers have asked:
how to mysqladmin flush-hosts on mysql database
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!