MyBB Community Forums

Full Version: Optimizations Techniques - MyBB 2.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Since MyBB 2.0 would be coded from scratch, there are some coding techniques that can take place.

First I would recommend that whenever possible double quotes to writing simple strings shouldn't be used, instead 1 quote will be used as PHP doesn't parse variables there.

For DB optimizations, the result queries should be placed in a member variable inside the DB class. New queries will be placed in that variable. If the variable is filled although a new query takes place, mysqli_free_result should be used.
And if there is a while loop with the use of fetch_array in its condition, inside the function if there is no more rows, the function will detect that and will execute mysqli_free_result automatically.


This of course would lead us to a coding habit of using mysqli_num_fields before of the while loop.

I thought about adding to a simple_select function a way to detect if a variable that is passed to it is a number and use intval on it to santize it and if it's a string to use the normal santize function and add the quotes there.


Sorry for my bad english, hope you understood.
It is likely the framework that we will use will handle most of this for us. Thanks for the ideas though - we're looking at making MyBB 2.0 as fast as we can make it. Smile
(2014-08-15, 04:00 PM)Jabberwock Wrote: [ -> ]First I would recommend that whenever possible double quotes to writing simple strings shouldn't be used, instead 1 quote will be used as PHP doesn't parse variables there.
There's not really much point in micro-optimizations like this.
The time saved would be so insignificant.
Since we're starting from scratch it won't hurt to do that - at least in the language files.
(2014-08-15, 04:59 PM)Axareal Wrote: [ -> ]
(2014-08-15, 04:00 PM)Jabberwock Wrote: [ -> ]First I would recommend that whenever possible double quotes to writing simple strings shouldn't be used, instead 1 quote will be used as PHP doesn't parse variables there.
There's not really much point in micro-optimizations like this.
The time saved would be so insignificant.

but for a big board, that time adds up
I think some decisions do need to be made regarding database types. Normalized databases make for a smaller footprint but require joins and thus more RAM. Denormalized is a bigger footprint but fewer joins so they are faster. Reads will always be more than writes, so it may be worth considering in some cases.
(2014-08-15, 05:47 PM)pavemen Wrote: [ -> ]
(2014-08-15, 04:59 PM)Axareal Wrote: [ -> ]
(2014-08-15, 04:00 PM)Jabberwock Wrote: [ -> ]First I would recommend that whenever possible double quotes to writing simple strings shouldn't be used, instead 1 quote will be used as PHP doesn't parse variables there.
There's not really much point in micro-optimizations like this.
The time saved would be so insignificant.

but for a big board, that time adds up

It never adds up in real-life. Database ceiling is simply so much lower than everything you can gain by micro tweaks like replacing double quotes with single ones for your strings, using isset($string[x]) instead of strlen() or all those "smart optimalizations" cool kids care about.
But if starting from scratch (as we will be for 2.0), it's best to follow best practices anyway Wink I agree it's doubtful you'll see any difference between them though.
Also guys, did you think about avoiding the use of the evil eval() function?
Yes, it's certain eval will not be used at all in 2.0.
Pages: 1 2 3 4