MyBB Community Forums

Full Version: mysql query running for a long time
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am running myBB 1.6 on my forums and am on hostgator shared webhosting plan.

I am frequently getting such alerts in my account
Quote:This query ran for 20 seconds. According to the HostGator Terms of Service, the maximum MySQL query runtime is 15 seconds.

(On an average I have 30-40 users on my forums at any given time.)
On contacting HG chat support, they advised me to optimize my database.

Does anyone has any experience with this? Any inputs would be appreciated.

Please let me know if you need some more info.
Any indication as to what the query actually was...??
We need to know what query is actually running to produce this error.
There are a number of queries which are causing such alerts. Some of them are -

DELETE from mybb_sessions where sid='bot=1'

Also find the attachments for sample of queries

[attachment=20821][attachment=20821][attachment=20821]


Please let me know if you need some more info.
The first DELETE query is a very simple query, there's no way that should be taking anywhere near 20 seconds to execute. The one selecting from the sessions table is pretty standard too. The last two queries aren't default queries so aren't something we can fix. The queries that are default don't take anywhere near this long for anybody else, and your database structure is the same as everybody else's.
You just need to do the following steps in phpMyAdmin (usually accessible from your cPanel)
  1. Choose your database, it should then show you a list of tables in the right hand pane.
  2. Scroll to the bottom.
  3. Click the link for "Check tables having overhead"
  4. Using the "With Selected" dropdown box choose Optimize table
  5. Once complete, you should be good to go.

You may want to do "Check All" instead of "Check tables having overhead" and just optimize the whole db since yours is so bad.

Some may also end up needing repaired. If so, repair them. Then optimize again.
How would this get so bad though?? Something to do with how the server's being managed??
(2010-12-17, 07:54 PM)MattRogowski Wrote: [ -> ]How would this get so bad though?? Something to do with how the server's being managed??

The answer is in the OP. Its Hostgator. I've seen this so many times with Hostgator that it makes me sick. Skin City Designs has removed their affiliation with them because of things like this.
(2010-12-17, 07:45 PM)MattRogowski Wrote: [ -> ]The first DELETE query is a very simple query, there's no way that should be taking anywhere near 20 seconds to execute. The one selecting from the sessions table is pretty standard too. The last two queries aren't default queries so aren't something we can fix. The queries that are default don't take anywhere near this long for anybody else, and your database structure is the same as everybody else's.
Well, it IS taking that much time and is mentioned multiple times in my CP. You have to believe me Smile
Also this was just the sample of queries, as I wrote earlier, there are many queries which is causing this.
(2010-12-17, 07:53 PM)Dylan M. Wrote: [ -> ]You just need to do the following steps in phpMyAdmin (usually accessible from your cPanel)
  1. Choose your database, it should then show you a list of tables in the right hand pane.
  2. Scroll to the bottom.
  3. Click the link for "Check tables having overhead"
  4. Using the "With Selected" dropdown box choose Optimize table
  5. Once complete, you should be good to go.

You may want to do "Check All" instead of "Check tables having overhead" and just optimize the whole db since yours is so bad.

Some may also end up needing repaired. If so, repair them. Then optimize again.
Thanks for the step-by-step instructions Dylan. I did as directed and will let you know if this solved the issue.
(2010-12-18, 06:53 AM)aj30 Wrote: [ -> ]
(2010-12-17, 07:45 PM)MattRogowski Wrote: [ -> ]The first DELETE query is a very simple query, there's no way that should be taking anywhere near 20 seconds to execute. The one selecting from the sessions table is pretty standard too. The last two queries aren't default queries so aren't something we can fix. The queries that are default don't take anywhere near this long for anybody else, and your database structure is the same as everybody else's.
Well, it IS taking that much time and is mentioned multiple times in my CP. You have to believe me Smile

Then it is an issue with your host. You can try optimizing all your tables, but if your tables are getting in such a state that it takes 20 seconds to run a delete query, it's nothing we can fix. A lot of people have poor performance on Hostgator. As I said, you're using the same files and the same database structure as every other user, and delete queries don't take 20 seconds for any of them.
Pages: 1 2