skip to Main Content

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


  1. A better approach would be to improve the indexing of usermeta as described in

    http://mysql.rjweb.org/doc.php/index_cookbook_mysql#speeding_up_wp_postmeta

    (That discusses postmeta adjust as needed to modify usermeta.)

    Login or Signup to reply.
  2. 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

    function delete_useless_post_meta() {
       global $wpdb;
       $table = $wpdb->prefix.'postmeta';
       $wpdb->delete ($table, array('meta_key' => '_edit_last'));
       $wpdb->delete ($table, array('meta_key' => '_edit_lock'));
       $wpdb->delete ($table, array('meta_key' => '_wp_old_slug')); }
    add_action('wp_logout','delete_useless_post_meta');
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search