MyBB Community Forums

Full Version: Small code optimization
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Recently I reviewed the code of MyBB and I have one question, why in file mysql_db_inserts.php we have:
$inserts[] = "INSERT INTO mybb_icons (iid, name, path) VALUES(1, 'Bug', 'images/icons/bug.gif');";
$inserts[] = "INSERT INTO mybb_icons (iid, name, path) VALUES(2, 'Exclamation', 'images/icons/exclamation.gif');";
$inserts[] = "INSERT INTO mybb_icons (iid, name, path) VALUES(3, 'Question', 'images/icons/question.gif');";
I give there only 3 queries, but in file is there much more.

Is not it better to use this for example:
$inserts[] = "INSERT INTO mybb_icons (iid, name, path) VALUES
(1, 'Bug', 'images/icons/bug.gif'),
(2, 'Exclamation', 'images/icons/exclamation.gif'),
(3, 'Question', 'images/icons/question.gif');";

I think, this method will perform faster. I know that installation is carried out only once, So how can you check it out.

GyniO
Is it really that big of a deal...?? It's an installation script... I don't think it's worth the developers wasting time rewriting the installer to just run less queries instead of fixing actual bugs.
I know, this is installation script, but We should pay attention to such exceptions, and the install script will execute much faster.

This optimization of the weak hosting can bring big benefits.
We should optimize everything is in position to be optimized.

Sorry for my bad english Wink

GyniO
The installation script takes a matter of seconds to run as it is, nobody has said they've had to sit there for ages whilst it installs, and nobody will be able to notice any speed increase achieved by changing the queries. Even a poor host won't take ages to run the installer.
Matt, but the prescription of such a file is less than 5 minutes of work, the effect may not be visible to the naked eye, but it is.

And so mybb RAM generates greater burden than any other forum engines.

My edit code (3 minutes of work):
http://s1.gynio.pl/mybbtest/mysql_db_inserts.txt


http://s1.gynio.pl/mybbtest/ <-- test

Standard mysql_db_inserts.php:
Queries: 129
Total Time: 0.01723504s
Total Memory Usage: 85.72 kb
---------------------------------
Edited mysql_db_inserts.php:
Queries: 11
Total Time: 0.00334787s
Total Memory Usage: 15.72 kb
---------------------------------
The difference the new file mysql_db_inserts.php:
Queries: 118
Total Time: 0.01388717s
Total Memory Usage: 70 kb
---------------------------------
For a one-time thing such as installing, imo this isn't a big deal - nonetheless, however, it's a small change and should be considered I think, since it'd only take a matter of minutes to clean it up.
I'd rather the developers spend their time o bug and new code than the installation script (and related SVN tracking and docs, QA, etc)

The install script is run one time by a single user, where as the main MyBB code is run over and over by more than one user.
I know that this is the install script, and I know that the code itself is an important forum. But such a trifle is a maximum of three minutes (because so much is I did).

Anyway, it is optimization patch, you should take this into attention.
Longer can you write there a post, than you would do this patchSmile

I'm sorry that so lean, but it is for the good MyBBSmile

P.S file is weight 15kb, no 25kb Toungue
Separating queries makes it easier to debug if things go wrong in the installation process.
(2011-01-24, 08:33 AM)Tomm M Wrote: [ -> ]Separating queries makes it easier to debug if things go wrong in the installation process.

You have absolutely right, but here is a very small probability of error.

Well then, I wrote what you can do with it, and what you do is leave the team.

Pages: 1 2