Optimize a table in MySQL from phpMyAdmin
Posted September 6th, 2008 in MySql
Yesterday I looked at how to Optimize a table in MySQL from the command line interface and today will look at how to do the same thing with phpMyAdmin. This means you can just point and click in a web based interface instead of having to remember the commands and type them in.
To check if there's a lot of wasted free space in any of your MySQL tables, log into phpMyAdmin and select your database. The initial view in the right frame is a list of all the tables in the database and shows an overview of each table including the number of records, size and overhead. This is shown in the screenshot below.

The second table in the above example has just 687 records and is taking up 545.3 MB. There's 533.5MB of "overhead" meaning free space which isn't being used at all but is taking up disk space. This table clearly isn't optimal so follow the steps below to optimize it.
Select the appropriate table by clicking one of the buttons alongside its name (one of the browse, structure, search or insert buttons) and the click the "Operations" button/tab at the top of the page. (Don't click the "Operations" tab on table list page as it will show a different set of operations which relate to the database as a whole instead of the specific table).

Now scroll to the bottom of the page until you find the "Table maintenance" options as shown in the screenshot below. To optimize the table click the "Optimize table" link.

The table will then be optimised and then after a few seconds the page will display the query as shown in the screenshot below.

If we then return to the page displaying the complete list of tables we can now see the table is only 33.1MB in size and there's no overhead.

If you have phpMyAdmin installed this is a much easier method than doing it from the command line because you can easily see which tables need to be optimised and easily optimise them by just clicking a few links.
Tomorrow I'll look at how to automatically optimize MySQL tables if they have become non-optimal using a PHP script.
Related posts:
- Optimize tables in MySQL automatically with PHP (Sunday, September 7th 2008)
- Optimize a table in MySQL from the command line interface (Thursday, September 4th 2008)
Recent posts:
- List installed packages with YUM (Tuesday, December 2nd 2008)
- Monthly Roundup - November 2008 (Monday, December 1st 2008)
- Weekly Roundup - December 1st 2008 (Monday, December 1st 2008)
- Installing subversion on CentOS (Sunday, November 30th 2008)
- GoDaddy 99 cent .com domain coupon code (Saturday, November 29th 2008)
- Find the index of a string within a string with Javascript (Friday, November 28th 2008)
Subscribe to RSS Feed / Email / Bookmark / Share
Use the buttons below to subscribe to my RSS feed to be notified next time something is posted, share this post with others, or subscribe by email and have my posts sent in a daily email.
