• Code that is run via a plugin or functions.php exists on the webserver but Code Snippets appears to store its code in the database. Does this mean that each time WordPress runs (e.g. on a page refresh) it has to query the database?

    This seems like it would be OK for a development and test site, but not a production site due to increased performance lag querying the database each time.

    Could you please help me understand the performance impact of running this plugin on production sites?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi tictag,

    Yes, on each page load, the database is queried to fetch the active snippets. However, this is just one query out of the many that are run with every page load simply as a part of having WordPress installed.

    The actual performance impact that this query will have depends on how performant your server is, and how many snippets you have, along with how many lines of code need to be fetched. I imagine that on most sites this is pretty negligible – on my site, it takes around 0.0003 seconds.

    If you want to check on your own site, I recommend the Query Monitor plugin – once installed, you can open the panel, go to the Queries section, and look how long it took to run the query beginning with SELECT FROM wp_snippets (where wp_ is your WordPress database table prefix).

    Thread Starter David Adams

    (@tictag)

    0.0003 seconds certainly sounds reasonable :-), though I do wonder how many snippets were included in your test. I will have around 100 if I implement this plugin. How much of a performance delay would 100 snippets create on each page load? 100 x 0.0003 seconds?

    Plugin Author Shea Bunge

    (@bungeshea)

    I doubt it would scale linearly like that – there would be a fair amount of overhead just for sending a query and getting back a result, irrespective of the sort of query and data.

    I had around 10 snippets active when I checked how long the query took. I can test with 100 if you’re still curious, but it’s probably going to be more reliable if you install Query Monitor and test on your own server, as that will likely have more of an impact than the number of snippets.

    Thread Starter David Adams

    (@tictag)

    Happy to install Query Monitor, I’ve used it in the past. I suppose I don’t want to go through the process of transferring all my custom code to Code Snippets (build/test etc) if I then end up un-installing it due to a performance issue. That’s really the point of this query.

    It would certainly help me to decide whether the investment in time is warranted. May I take you up on your offer?

    My website pages currently return in about 1.1 seconds, and there’s more that can be done to improve that. So there’s a pretty reasonable ‘visitor experience’ as they click around the site. If installing Code Snippet added, say, more than 0.5 seconds, that would be unacceptable because the user experience would suffer, just because of the ‘convenience’ of having custom code delivered in a more intuitive way i.e. to help me. If delivering 100 snippets impacted less than, say, 0.1 seconds, then I would install it tomorrow!

    I suggest you look at Redis as an object cache for WordPress, and WP Rocket as a front-end cache which will create static HTML files so your webserver will deliver those instead of going the expensive Apache/MySQL dynamic route for each request.

    • This reply was modified 3 years, 8 months ago by ablears.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Code Snippets in Production?’ is closed to new replies.