What are unused usermeta?
User metadata, stored in the wp_usermeta table, holds additional data for each user account such as roles, preferences, and plugin settings. Over time, when users are deleted or plugins stop using certain meta keys, leftover usermeta entries can remain in the database even though they no longer belong to any existing user – these are called unused usermeta.
How they affect your database?
Unused usermeta clutter the wp_usermeta table, increase database size, and can slightly slow down queries that fetch user information. They also add unnecessary weight to backups, especially on large sites with many registered users.
How to clean them?
1. Using Advanced Database Cleaner plugin
You can safely clean unused usermeta using the General Cleanup module in Advanced Database Cleaner plugin.
The plugin automatically detects usermeta that belong to deleted users and allows you to:
- Remove all unused usermeta in one click.
- Schedule regular cleanups to maintain a tidy
wp_usermetatable.
2. Using a raw SQL query
If you prefer manual cleanup, you can run this SQL command in phpMyAdmin for example:
DELETE um FROM wp_usermeta um LEFT JOIN wp_users u ON u.ID = um.user_id WHERE u.ID IS NULL;
Note:
While you can manually run these SQL commands to clean unused usermeta, we strongly recommend using the Advanced Database Cleaner plugin.
It uses WordPress’s internal cleaning methods, automatically handles multisite installations, and ensures that all related data is safely removed while keeping your database consistent and stable.