How to make sure a table isn't being used in phpMyAdmin

I use WordPress and believe the database is full of tables from plug-ins past… not sure exactly, but I’d like to clear them out if so. Is it safe to delete any table with a 0 record? You can’t browse these rows so I assume it is safe to delete unless that’s not always the case.

Thanks!

You could do an additional, fresh install of your WP version and the plug-ins you want then compare the databases.

If there are tables in your original database that aren’t in the new one, you should be safe to delete them.

Yes you are required to do a bit of homework.

If you’re suggesting that I believe anything comes easy in this life you’d be mistaken sir ;).

Appreciate -

USE my_wordpress_db;
SHOW TABLE STATUS;

I don’t remember which storage engine Wordpress uses, but that may give you some details about your tables, one of which is “update_time” which if relatively recent, is a good indicator that the table is in use.

Now, an old update time isn’t a guarantee that the table is not in use, but if it’s a table that only stores a few rows temporarily and you just never happen to catch it when there’s rows in it, that update time could save you from deleting the table.

SHOW OPEN TABLES;

This one is tricky. If you see a table listed in the results of that query, it’s a solid indication that the table has been used somewhere.

However, if you’ve been poking around in phpMyAdmin there’s a good chance the information you get from it is tainted since looking at the table via phpMyAdmin will open the table.
It would be a good idea to use FLUSH TABLES on the suspect tables and then waiting a day or so before checking the list of open tables again.

FLUSH TABLES suspect_table_one, suspect_table_two;

There’s also the chance that your table_cache is small, and that the suspect table has been cycled out of the list by the time you’ve checked it.

I’d just leave the tables there. If there aren’t any rows in them anyway they won’t be using much disk psace.

The trouble you might get from deleting a required table is not worth the couple of bytes you might save here and there.

Not safe, no. Just cause a table has zero records doesn’t mean it’s not being used. Your best off figuring out which are actively required by compiling a list of plugins you want and their associated tables, etc.

Yes you are required to do a bit of homework.

Cheers,
Alex