MyBB Community Forums

Full Version: How does the template system work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Right. I once tried writing my own template system and loaded templates from MySQL....it was slow as hell. Considering it was only HTML.

How did mybb achieve such speed? Is it the caching? I looked at the caching of templates...and it's not really caching. You just store the template in an array which means it all goes to the memory(ram?).

So that means that in order for mybb to be fast, it sacrifices memory.

Is my logic true or false(and why if not)?
Yes, it selects all the templates that will be used on the page at the start of the script and stores them in an array, running just one query. On this forum, the query to select the templates for this page took 0.0001 seconds. I'd say storing it in memory like this though is better than more queries.
I also requested one template with one query with my method, but the loading(on localhost) was like 3-4 seconds, maybe even more.
Here, you get all the templates with one query, which is way more than me, and page loading is as fast as it can be.
If it took that long it sounds like you're missing indexes or something, but a simple select query shouldn't take that long even with no indexes, unless there were like millions of records in the table or something.
No, it was just for testing purposes with a few lines of HTML and just one row. But since my knowledge Database design is low, i didn't know i had to index them..
If that's all that was in there and it was still taking that long to run the query to select it then you must have had something seriously misconfigured somewhere. But without knowing anything about the code you wrote we can't do anything about it.
Well, my question was primarily aimed at MyBB's template system's speed. As for my own, i have created another one in the appropriate forum.

I'll mark this as solved now.