MyBB Community Forums

Full Version: Unnecessary select queries on mybb_sessions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For context, I'm trying to reduce SQL usage on my forum. I've discovered that the script continues to perform select queries on the sessions table for thread pages and forum pages despite disabling "show users browsing this thread/forum". This is based on the debugger information and my own analysis of the script itself.

I understand the importance of write queries, as this allows the script to track who's online and who isn't -- I'm not interested in disabling SQL writes to the sessions table. Even after disabling showing who's browsing threads and forum pages, MyBB continues to do select queries on this table (which has > 7000 rows on my forum). Showing who's online is still enabled for the index as this gives members a feeling for how busy the forum is, which is a plus.

Which core files should I edit to prevent MyBB from performing select queries when showthread.php and forumdisplay.php are executed? To reiterate, I've disabled the feature to show who's browsing what on all pages except the index, and in spite of this, MyBB carries on doing select queries for pages other than the index when it absolutely isn't needed.

For showthread.php, the code appears to begin at line 1489. Is there a straightforward edit one can make?

Edit: It just occurred to me that the online status indicator displayed in threads (next to member avatars) probably needs to query the sessions table. It's still something I could get away with disabling on forumdisplay.php though.
With the Forum Display Options → Users Browsing this Forum setting off, these 2 queries shouldn't be executed:
https://github.com/mybb/mybb/blob/mybb_1...#L286-L297

With the Show Thread Options → Users Browsing this Thread setting off, these 2 queries shouldn't be executed:
https://github.com/mybb/mybb/blob/mybb_1...1522-L1533

The Online status is based on data in the mybb_users table, but there are other 2 queries related to the visitor's session (SELECT and UPDATE), executed early in the process. These only relate to specific rows, so it shouldn't have a significant impact on performance (and usually the SELECT one is faster than UPDATE).
(2020-01-12, 01:46 PM)Devilshakerz Wrote: [ -> ]With the Forum Display Options → Users Browsing this Forum setting off, these 2 queries shouldn't be executed:
https://github.com/mybb/mybb/blob/mybb_1...#L286-L297

With the Show Thread Options → Users Browsing this Thread setting off, these 2 queries shouldn't be executed:
https://github.com/mybb/mybb/blob/mybb_1...1522-L1533

The Online status is based on data in the mybb_users table, but there are other 2 queries related to the visitor's session (SELECT and UPDATE), executed early in the process. These only relate to specific rows, so it shouldn't have a significant impact on performance (and usually the SELECT one is faster than UPDATE).

Thanks so much! I'll give this a shot and see how it goes.