Jump to content

MySQL Table Optimization, which ones?


Recommended Posts

Posted

Hello IPB,

I have a BIG forum, which has my CPU usage pretty high.

I have already optimized a load of things, but high cpu usage remains.

My Host has told me that I should optimize my forums MySQL Database / it's tables.

I would like to know, which tables can and/or should be optimized.. and hopefully lower my CPU usage a bit without breaking the forum in some way.

Please let me know, I need this ASAP.

Posted

Hi

If you use PhpMyAdmin its very easy. View your database in PhpMyAdmin, using the Structure tab. Scroll down and look at the very bottom of your board's database.

It will show you the amount of any overhead (which is inevitable and builds up the more your database gets used) in Mebibytes (Mib).

(highlighted in yellow on the attached image)

Just click on the link that says "Check tables having overhead" and then click on Optimise table from the drop down list of options where it says "With Selected".

post-34851-0-15014100-1359911584_thumb.j

It may take a few minutes depending upon the size of your database, after which it will be optimised.

You may wish to back it up first.

Posted

If you're not optimizing your database regularly then first time around I would suggest doing a few tables at a time. If you do the whole lot you may run into problems.

I do mine once a week as described above. Theoretically you shouldn't need to do this if you're running 3.4 as there's a scheduler task that does this once a day. I find however that I still need to optimize manually as my database is too big, checking the scheduler task log, the optimize task runs every day but no tables are optimized.

Posted

How large is your forum database, in MB or GB?

If we're talking GB, you should be very careful about optimizing large tables without first analyzing the size of each table, and understanding the resources and time required to optimize them.

It's generally a smooth process, but only if your MySQL server is optimized to handle large datasets, you don't want MySQL to run out of tmp space when working on rebuilding or optimizing large tables. If you're optimizing your posts table, likely the largest part of the database, it's may lock your forum database for quite some time while it works, your site will be unusable and may display database errors. It's best to take your forum offline, because the process can take a few minutes.

Posted

It's about 70MB.

I have blocked some bots right now in CPanel on IP.Deny, and tell you the truth, has done a GAZILLION TIMES better effect than that garbage .httaccess file

I'm still looking for ways to reduce it more.

Posted

At 70MB, you should be able to safely optimize your tables without much worry, as per the advice The Old Man gave you above. Considering putting your forums in 'offline mode' just to be safe, but I imagine it will be a quick process to optimize.

Posted

Run this from shell and be done with it:

mysqlcheck -u root -p --optimize --all-databases
 

Thanks. Quicker than doing it via PhpMyAdmin however this appears to optimize all tables whether they need or not and places a big load on my server.

Posted

Thanks. Quicker than doing it via PhpMyAdmin however this appears to optimize all tables whether they need or not and places a big load on my server.

If the table is already optimized then it would say nothing to optimize. I optimize 2Gb of database in just few minutes, It's boring for me to do one by one.. and I do't have innodb tables much so it's fast for me.

I had read someone where that never optimize innodb tables cos it would put super high load on server.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...