Performance Notes
We are often asked about the number of database queries that get actioned and about performance issues in general when you have Simple:Press Forum installed on your site. Hopefully, some of those questions will be answered below. But first, a quick word on our development policy.
Development policy
A large portion of our development time is spent on optimization, both of our code and our database queries. It tends to be the first task – and sometimes the longest task – of each major development cycle. Wherever possible, calls to the database are minimized, functions re-written and code pruned. This is an ongoing process and will continue with every release.
That being said it has to be recognised that Simple:Press Forum is a large and feature rich plugin. Unlike a blog – which tends to be fairly static, a forum is also dynamic and a busy forum can have changes being made to it on a continual basis. Overall performance and database activity is therefore a balancing act between what features users want and request and how those features can be integrated into the whole with as little overhead as possible.
Features, features, features!
We receive a huge number of requests for new features. We do not include them all but do consider any feature that is requested multiple times and many that just make plain sense. But each and every new feature will add more code and will almost certainly require new database queries. That is the cost. This does not necessarily result in a slow down of the forum but it does make the codebase bigger.
If, as a user, you want a very lightweight and bare-bones forum then perhaps Simple:Press should not be your choice. If, on the other hand, you want the features and scalability that Simple:Press Forum has to offer then you have to accept an increase in database activity and code base.
That’s a lot of files!
Yes – it is a lot of files. But don’t worry – they are not all loaded all of the time. Wherever possible we only load those code files that are necessary for whatever view is being displayed or operation being carried out.
Additionally, as the forum progresses, we are using more AJAX type operations so that data can be presented when the user wants it – not loaded in the background ready. This helps the size of the pages being loaded.
We do, currently, need to load some code even when the forum is not being displayed. This can not be helped. As a bare minimum we need to load code that checks whether the current view is a forum view and also need to load support for any template tags the user may have set up. We also ensure that any Javascript code is only loaded on forum views – both within the front-end forum and the back end administration.
And a lot of database queries!
There are a lot of misconceptions regarding the number of database queries any plugin can make. Simple:Press Forum does add a noticeable amount of new queries to your site and this is a consequence of being a feature rich plugin and also having a dynamic data requirement where database records are constantly being updated.
There are two main points to make here. The first is that MySQL is a very robust database engine that can handle a large number of queries on huge volumes of data with ease. A standard WordPress blog hardly scratches the surface of MySQL’s capabilities. Additionally, MySQL is very good at caching it’s data and on most installations the vast majority of data will actually be retrieved from memory – especially those queries that are repeatedly run. The bottom line is that the effect on overall performance should be marginal.
We are a little hampered by the need to support older versions of MySQL but until newer versions become commonplace at hosts and WordPress itself steps up to require new MySQL features we will continue to support the oldest version possible.
What can I do to improve performance?
Quite a lot actually. But start by considering the following points:
- Give some thought to your hosting: If you have a busy and popular site and the forum is going to be an integral part of that, overall performance starts with your host. The basic truth is that you get what you pay for. Generally speaking, the cheaper the hosting package the more you will see performance and loading issues – and not just with the forum. A webserver shared amongst large numbers of websites is already a bottleneck. Choose your hosting with care and be prepared to pay more if you want more.
- Your number of forums: The more forums you define the bigger the number of database queries and returned data that needs to be processed and displayed. Defining large quantities of forums is also not really a good policy for your users either who will tend to get lost scrolling through them. Plan out your forums with care and keep them to a minimum.
- Number of topics and posts displayed: This is, of course, a trade off between smaller queries to return smaller topic/post lists and the possibility of requiring multiple pages to display them. The question is – how busy is your forum? If most topics do not spread across multiple pages keep the post list smaller.
- Consider your options: Our experience on the support forum shows that very few users take time to consider, review and plan for the options that we have made available. We get many questions repeatedly that require a simple trip to the forum options to turn on or off a feature. Time spent looking through the options can be helpful as there are many items that can be turned off that you may not want and that will reduce both queries and rendering time. If you don’t need it – why keep it!
- What about the components: The same is true for the forum ‘components’ – essentially add ons and extensions. Take time to decide if you really need them.
- So – who can do what?: Review your User Groups and Permission Sets and ensure you have the smallest number of each defined for your purposes. And double check the permissions you are granting your guests and users. Many of those permissions, when made available, will result in extra database queries and code being included.
Use Forum Configuration
As already noted, Simple:Press Forum has a lot of folders and files. One problem with this is that there are some operations that require WordPress to perform folder scans and the larger the collection of folders and files the longer those scans take. Additionally, some of those files are available for user customization and should not get overwritten by a later upgrade.
To remedy both of these issues it is worth considering use of the built in Configuration options. Accessed from the admin panels, this allows many folders to be moved outside of the WordPress plugin folder and placed in ‘wp-content’. Folders such as ‘styles’ and ‘icons’ for example. Making full use of these configuration options will both aid performance and place customized files safely out of the way of the next forum update.
Code and Query Optimizations
It is possible to turn off some features that you do not wish to use and prevent the code for those features being loaded. And saving of file loading is worth taking advantage of. This is mainly in the area of template tags which allow you to show forum data and information outside of the forum pages themselves.
