1) First of all Login to your PHPmyadmin DB management area.
2) Now from the left sidebar select the desired database.
3) Now Check All the table entries and click ‘Check Table’ option from the drop down menu and it will run a query.
4) After this go back to that database again and select all the table entries. Now select ‘Optimize Table’ option from the menu.
5) That’s all. The menu has many different options like Repair, Drop, Empty and so on. So use them carefully. Never select Drop or Empty option. Else it will ruin your DB.
If you follow the above step for a WordPress blog then it might be possible that your Post pages may not work properly or show 404 error. To solve it just go to your WordPress Admin Panel and Click on ‘Permalinks’ under Settings menu and just click on Save Changes button. Don’t make any changes! It will start working fine again.