0

I have a question about the performance of my plugin.

On the settings page of my plugin I have about 20 options the user can change (checkboxes, dropdown and normal text inputs). Currently I just update all options on submitting the form.

Is it better for performance to first check if an option is updated before I really update the option? So that it doesn't write to the database if the option isn't changed?

2

update_option() does this for you already:

// If the new and old values are the same, no need to update.
if ( $value === $old_value )
    return false;

No need to worry about it. :)

Note that if you have a lot of options, which are not autoloaded, this might cause excessive read queries. This applies to general operation too, not just updates.

  • How do u autoload/update options? – Danny van Holten Sep 10 '14 at 10:36
  • See add_option() documentation for details on autoload, by default it's enabled. – Rarst Sep 10 '14 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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