1

Is there no mechanism which purges old options from the DB? I tried a few plugins in the past and I found out that there are a few pretty long option strings which are set to autoload but IMHO not used at all - as I'm not using those plugins anymore.

So I guess it makes sense to remove those options completely - but I'm not 100% sure whether I miss some implications? Am I mistaken, or this the unfortunate result of bad plugins which really needs individual optimization every now and than?

Thanks

EDIT: Some theoreticaly reference to autoloaded orphaned options: Is deleting orphaned wp_options entries safe?

2
  • I'm not sure how there could be any mechanism - it would need to know exactly which options were used by every plugin on the site, which isn't possible.
    – vancoder
    Nov 24, 2021 at 18:35
  • Potentially it could be done that one keeps logging all used options (by hooking into get_options()) over a period of time, e.g. one month of using the page in and out with hundreds of users online (which is the case for me) - yes it creates some logging overhead, BUT this way, one could find the options most likely never being used and delete them or at least set them to autoload=no.
    – tim
    Nov 25, 2021 at 14:45

1 Answer 1

1

Do you have access to a SQL client program like phpmyadmin or something similar?

If so give this query

SELECT option_id, option_name, LENGTH(option_value)
  FROM wp_options
 WHERE autoload = 'yes'
   AND option_name NOT LIKE '_transient%'
 ORDER BY 3 DESC
 LIMIT 20;

You'll see the top twenty auto loaded options in descending order of length.

Eyeball the option names. You may recognize some that were placed there by a plugin or theme you have discontinued using.

If you see one you don't need, look at its option_id then give this SQL statement.

DELETE FROM wp_options WHERE option_id = <<the option id>>

If you do this ten times or so you'll get rid of the biggest and ugliest orphan options.

And, if you install a persistent object cache like memcached or Redis you'll mitigate a lot of the performance trouble caused by orphan options.

Finally, plugin and theme authors are expected to write uninstall modules to remove their options and other data upon deletion (not deactivation). But many authors ignore this part of their task.

So, you can try deleting your inactive plugins. That may or may not delete their options too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.