Repair and optimize WordPress database

It is always good practice to optimize your blog’s database to improve blog’s performance. Many are not aware about WordPress’s built-in database repair and optimize functionality, as it is not available in admin back-end.

You can check this by visiting (replace with your actual blog/site url ).

Below is a step by step guide on how to optimize WordPress database :

  1. First login to admin section of WordPress blog by visiting .
  2. Then go to .You can see screen as show below. It ask you to add a line of code to WordPress’s wp-config.php file.
  3. Add below code to your WordPress wp-config.php file and reload/refresh page.
  4. define('WP_ALLOW_REPAIR', true);

  5. After refreshing you can see page with options to ‘Repair Database’ and to ‘Repair and Optimize Database’. Just click on one of the option.
  6. If you click on ‘Repair Database’ button,  WordPress can automatically look for some common database problems and repair them. Internally it executes two sql queries on each WordPress database tables in loop and these queries are CHECK TABLE  table_name and REPAIR TABLE  table_name .
  7. If you click on ‘Repair and Optimize Database’ button, WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing. Internally it executes four sql queries along with above two queries on each WordPress database tables in loop and other two queries are ANALYZE TABLE  table_name and OPTIMIZE TABLE  table_name .

Hope this will improve your WordPress blog’s performance. Drop in your comments!

(P.S. : Please take backup of your WordPress database before making any action on database)

No related posts.


 Share your views
  1. Do I need to remove define('WP_ALLOW_REPAIR', true); after optimizing?

  2. [...] Once you do that, you’ll see dual options on that page: correct database, correct and optimize database. Simply click the choice of your choice and WordPress will do the rest. If you’re looking for a step-by-step beam on this, you can find it on WPveda. [...]

  3. which is the best way to optimize wordpress, phpmyadmin or using your tutorial??

  4. both are options and not the optimization utility. using both option you can perform the same operation, as mentioned in post

  5. Thanks! i did it but there is still something wrong on my database… subscribers can not see their profile, they get an error message telling that they don’t have enough privileges to see the page… any idea of what maybe the problem?

  6. Thanks for showing me how to do this. Valuable. Im surprise WP admin doesn’t have a button to do this. I never knew it existed.


Leave a Comment

  • Facebook
  • GitHub
  • Twitter
  • LinkedIn
  • Google

Your email address will not be published.