• Right now, you put PHP code in the DB (PHP code snippet), which means that before executing the page, you ask the DB to load more PHP stuff. Your DB is a real bottle neck and is on its knees once using code snippet together with all other plugins a site use or needs.

    Why can’t you load the code as a plugin code instead of from the db?

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

    (@bungeshea)

    Hi @alriksson,

    It’s true that executing a database query will have an impact on the load time of your website. However, it’s important to keep in mind that there are already a number of database queries that are run simply as a part of having WordPress installed, and this is just one additional query.

    If you’re really concerned that Code Snippets is having a performance impact on your site, I recommend the Query Monitor plugin for actually measuring how long that query takes. On my site it takes 0.0003 seconds.

    Thread Starter Rookie

    (@alriksson)

    True but it also an issue of execution order and what I know we should not need to involve the db to execute php.

    Not a developer but I think there could be room for improvements, on your site is it heavy or light or just a simple site you spinned up now to check?
    Please show me where in QM I can find code snippets queries.

    Plugin Author Shea Bunge

    (@bungeshea)

    The other option would be to store snippet code as files on the filesystem. This is something we can look into adding in the future, but my concern would be that gaining filesystem access can be tricky to do effectively on many hosts, due to inconsistent permissions or particular server configurations, making it less of a reliable method.

    The site is my personal website where I use the plugin – not a testing site or one I made on the fly. The time will of course change depending on the server and how many snippets you have.

    If you have Query Monitor installed and the panel open (by clicking on the item in the admin bar), you’ll find the snippets database query by looking under the ‘Queries’ section and scrolling down until you see a query that starts like this:

    SELECT id, code, scope
    FROM wp_snippets
    Thread Starter Rookie

    (@alriksson)

    The other option would be to store snippet code as files on the filesystem. This is something we can look into adding in the future, but my concern would be that gaining filesystem access can be tricky to do effectively on many hosts, due to inconsistent permissions or particular server configurations, making it less of a reliable method.

    Most performance and cache plugin require don’t think this would be a big issue but maybe less reliable. But why not add options to choose and by default use sql and db if possible? And once enable the file function ask one more time and maybe add a function to check if your plugin is able to write in the filesystem, as many other plugins do by checking and if not link to a documentation page for further information to debug and last outcome go back to sql/db for the user. As you say some may not allow due to firewalls etc but still think most will have a hassle free experience consider the norm of use of cache plugin which normally need to have access.

    Just suggesting here 🙂

    If you have Query Monitor installed and the panel open (by clicking on the item in the admin bar), you’ll find the snippets database query by looking under the ‘Queries’ section and scrolling down until you see a query that starts like this:

    SELECT id, code, scope
    FROM wp_snippets

    Thanks, looks ok as you said so you have a point about it not being slow. But to me it sounds and what I heard from other using code snippet. Why in the world query sql to db to execute php if you understand.

    And my main issue is also the other ticket where it is executed too late. But I love the UI so would like to keep the plugin

    Thread Starter Rookie

    (@alriksson)

    I would use taxonomy terms as wordpress cache this rather than involving the db and write to files and then parse them for data as it’s faster. Maybe something you could look into.

    Plugin Author Shea Bunge

    (@bungeshea)

    I’m a little unsure how storing data as taxonomy terms would speed things up. As far as I can tell, the current method of using a custom table incurs the least overhead because there’s no need to store unnecessary metadata, and the important fields can be indexed.

    I agree it would be beneficial to write to files for execution, and this is definitely something we are considering.

    Thread Starter Rookie

    (@alriksson)

    Wordpress cache taxonomy terms by default.

    Write to files may not be faster than taxonomy terms would it? I’m just elaborating on improvements but as far as I know taxonomy terms would be faster but correct me if I’m wrong.

    Plugin Author Shea Bunge

    (@bungeshea)

    Taxonomy terms would not be faster than the current solution. It would still involve reading/writing from the database, and with additional overhead.

    Writing to files would need to happen at the point when a snippet is saved, and then that would (likely) speed up loading the snippets for execution. It does have a higher potential to create issues on certain hosts, however, which is why it is not currently the method we use.

    Thread Starter Rookie

    (@alriksson)

    I might be wrong, suggesting her,e but wordpress taxonomty terms are cached by default in wordpress. So no queries is needed.

    Feels like it’s faster than what’s today but maybe not faster than writing to files.

    Plugin Author Shea Bunge

    (@bungeshea)

    I’m not sure what you mean by ‘cached by default’. All WordPress data is stored in the database, and so it must be fetched from the database at least once every page load, unless you have some sort of persistent caching software installed.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Improve code and logic’ is closed to new replies.