I’m having performance issues with my WordPress site, due to the number of registered users, the wp_usermeta
table has almost 70 million rows.
Users do not have access to modify their profile so I have thought about deleting the unnecessary metadata that WordPress creates when registering a new user. The following rows are created for a normal user:
+----------------------+------------------------------+
| meta_key | meta_value |
+----------------------+------------------------------+
| nickname | [USER_NICKNAME] |
| first_name | |
| last_name | |
| description | |
| rich_editing | true |
| syntax_highlighting | true |
| comment_shortcuts | false |
| admin_color | fresh |
| use_ssl | 0 |
| show_admin_bar_front | true |
| locale | |
| wpe_capabilities | a:1:{s:10:"subscriber";b:1;} |
| wpe_user_level | 0 |
| default_password_nag | |
| session_tokens | [SESSION_DATA] |
+----------------------+------------------------------+
I have thought of deleting all rows except nickname
and session_tokens
. Will i have a problem if i do this? Is there a way for WordPress to not create these rows for new users?
2
Answers
A better approach would be to improve the indexing of
usermeta
as described inhttp://mysql.rjweb.org/doc.php/index_cookbook_mysql#speeding_up_wp_postmeta
(That discusses
postmeta
adjust as needed to modifyusermeta
.)Yes it is safe.
Check this solution
This has been explained here in full.
Remove Unnecessary WP Postmeta
All you have to do is add the following in your theme functions.php file