Support » Plugin: iThemes Security (formerly Better WP Security) » small optimization – fewer queries on each page refresh

  • hi,

    I’m on “performance hunt” and I noticed that with each page refresh this plugin makes 5 queries with get_option. First I thought they are not autoloaded but looking in the database all ‘itsec_’ options have “autoload=yes” so it looks like those options aren’t added to database = not autoloaded. Once added, I don’t have those extra queries with each page refresh. Can you please add those options to database to make fewer mysql request?

    Thanks in advance :o)

Viewing 5 replies - 1 through 5 (of 5 total)
  • @kokers

    Both frontend and backend page refresh ?



    yep. I see those queries in the backend too. In the frontend for both logged in and logged out users.

    In the backend there is 13 queries in total called. Those 5 that show up in frontend + one (itsec_file_change_warning) I think could be added to database to cut those queries <- on screenshot there is 12 queries because I’ve added to database manually itsec_config_changed to see if this will cut the query and it did.

    Also just as an information, I use Query Monitor to debug


    Thank you for providing that extra info.

    Fixing this is not as easy as permanently saving these options in the database.

    The options probably need to be created in the database at activation of the plugin. And they need to be set to the proper default value. Otherwise these options will trigger actions that are not (yet) supposed to be triggered.

    Since these options are currently created/deleted other changes need to be made as well. The pieces of code that deletes the options needs to be removed or rewritten to set the value back to default after an action has been performed.

    Looking at your screenshots I noticed the relevant SQL queries run pretty fast. Which means there will not be any noticeable performance gain.
    I agree running less SQL statement on your database is a good thing but if there is no noticeable performance gain who cares …

    Another thing to consider is that ok so we can cut down on the number of SQL queries but saving the options permanently in the database with autoload=yes means there is more data loaded into memory at WordPress initialization. So you win a bit on one side of the diamond and loose a bit on the other side of the diamond.

    There are even some other considerations I’m not going to discuss here.

    What I’m trying to say is that this is more of a cosmetic thing.
    The effort is probably not worth the gain.

    But look at it on the bright side, iThemes might disagree with me (if they everrrrr read this post) 😉


    Thanks dwinden for your answer, not sure what’s your relation to this plugin but I noticed you’re very active here (unlike the authors ;o))

    If those options are loaded with each refresh, then loading them into memory isn’t a bad thing imo. But yes, if the whole code is build with add/delete then this isn’t something anyone could consider because yes, gain wouldn’t be THAT significant if you use few plugins. Though if you have more than a few, and each of them make few queries to options that do not exist in database, or simply aren’t autloaded, then this is worth to try to cut some of them, because if you consider whole wordpress installation and all plugins the gain could be significant.

    Anyway thanks again for taking time to answer :o)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘small optimization – fewer queries on each page refresh’ is closed to new replies.