Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've a self hosted wordpress blog. The server showing internal (500) server error and usually the system admins ask me to optimize my database. The database is relatively small in size and fits in few MBs. The error usually displaying is Fast CGI process.

The usual reply from admins are as below

As we have checked and found that you are using Mysql database and fetching database through php code from database server which is at remote location and in this process when queries are being more then PHP fast cgi application get hanged and that's why you are getting this issue, For this you should check code or database optimization

How can I optimize my database? I've installed a wordpress plugin to optimize my tables. Or is it a server problem?

share|improve this question

migrated from serverfault.com Jan 26 '11 at 9:13

This question came from our site for professional system and network administrators.

4 Answers 4

It probably is a host issue. Assuming that you're relatively stock Wordpress, the queries shouldn't be so inefficient that they're causing timeouts.

When it says a "remote mysql database", does that mean a remote database server with the same hosting company, or does it mean you're using a database server that's physically located somewhere else? If the latter, that could be your problem. Negotiating a MySQL connection then running a query requires a fair number of roundtrips, so if there's a lot of latency it could add up fast to approach the timeout.

Based on the rather canned-looking reply from the host, I'm willing to bet you're using some low-priced shared hosting. Unfortunately, almost all of those are terrible. After a year or two of having problem after problem with shared hosts, I gave up and went to a good VPS and have had no issues since. This may not be a problem for you though, if you're not willing and able to manage an entire virtual server for one small blog.

share|improve this answer

Are your database and web servers on same hosting and same hosting account? If you are trying to use remote database from another party this might indeed be way too slow.

If this is all in same account then your hosting is probably doing it wrong. For cheaper hosting database usually resides on same server, for more advanced hosting separate database servers resides nearby (reached by local network or whatever). If hosting cannot provide database access that is sufficiently fast and reachable - it is their problem with configuration, not your problem with tables/queries.

share|improve this answer

May be the problem not in your database size, but in your query. May be you use uneffective query or use sub-query that containt recursive recordset, could be your database server down.

share|improve this answer

I think you are using a shared hosting plan. I faced the same problem 5 months back but as soon as I upgraded to VPS, everything works like a magic and never had any issue regarding DB optimization.

If this is not the same with you then I would suggest you to use "WP OPTIMIZE" Plugin for wordpress which will optimize you database and remove all the unnecessary post revisions and stuffs like that.

Other than this, try deactivating plugins which are not vital for your blog, re-size the image in photoshop or any other image re-sizing software before uploading. If you can, reduce the size of the image with the help of some awesome image compression software.

Use a lightweight template with not more than 10 plugins.

Use w3total cache plugin along with cloudfare. This will reduce threats and extremely help you server to handle the traffic without crying.

If still the problem is not resolved, please upgrade your hosting plan. You may be using a plan where they say you will get "Unlimited storage, bandwidth, blah blah blah" but my friend unlimited doesn't means infinite. Your server admin calculated the amount of resources you will use and if you over the resources, it will eat up the CPU resources affecting fellow customers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.