Skip to main content
Topic: The queries countdown (Read 7426 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

The queries countdown

One of the "goals" is to move all the queries out of the controllers, well let's see after one year of work where we are.

I did a simple search of the code using $db->query, finding:
/controllers/ => 137
/admin/ => 96

Well, to be honest I hoped/had the feeling we were in a "better shape", though it's not that bad and we can (and should) improve. :P

To do a comparison with what we started in SMF I searched (excluding all the "Subs-*" and "db" files) $smcFunc['db_query, finding 1104 instances.
Bugs creator.
Features destroyer.
Template killer.

Re: The queries countdown

Reply #1

Well 1104 down to 233 is a pretty darn good start ... plus we MAY have added a query or two along they way :P

Agree we need to 'finish' the improvement job  :D

Re: The queries countdown

Reply #2

Quote from: Spuds – Well 1104 down to 233 is a pretty darn good start ... plus we MAY have added a query or two along they way :P
 emanuele is innocent! :P
Actually is +14 because I didn't notice the $db_search->search_query, so 247. Still a good reduction. :D

Quote from: Spuds – Agree we need to 'finish' the improvement job  :D
Yep!

In the meantime, an update after merging a couple of branches:
/controllers/ => 142
/admin/ => 88

And a bit of additional analysis.
Regarding the /admin/ dir:
RepairBoards.php is the one accounting for the relative majority of the queries: 39. That file is scary TBH...do we really need all this? Can it be reworked to use functions we already have? What do you think?
The second file in terms of queries is ManageAttachments, this is as usual a bit tricky I think...
Special case (I think) AdminDebug.controller.php: it has both queries and markup. I'm not sure if it is a special case, since I suppose it should just adhere to the standards of the rest of the code...or not?

The /controllers/ dir, instead, is more "messy", there are still 5 files with more than 10 queries:
PersonalMessage (20)
Recent (17)
RemoveTopic (16)
ProfileHistory (15)
* ProfileInfo (15)
Bugs creator.
Features destroyer.
Template killer.

Re: The queries countdown

Reply #3

Just made the pr for profile info, so knock 15 more off the list :)

Re: The queries countdown

Reply #4

Groups controller should be free of queries, too: PR is https://github.com/elkarte/Elkarte/pull/919

Thorsten "TE" Eurich
------------------------

Re: The queries countdown

Reply #5

YAY!

OK, this is extremely refreshing for the codebase, and incomparable by a great length with SMF. And unbelievable, how fast you folks went through it.

@Trek,
How about you grumble at us meanies to give you details on this reasons -> progress -> achievement -> consequences, then please, help shape up our mumbling into a decent form.
For the mid-level development documentation (changes from SMF, Elk presentation, oriented dev-wise). We have similar github wiki pages already, they just want added to. ;)
The best moment for testing your PR is right after you merge it. Can't miss with that one.

Re: The queries countdown

Reply #6

And update after the last merges:
/controllers/ => 122 (110+12)
/admin/ => 76 (74+2)
Grand total: 198

Under the 200! YAY!

Next goal is 100! ;D
Bugs creator.
Features destroyer.
Template killer.

Re: The queries countdown

Reply #7

Another week and:
/controllers/ => 113 (101+12)
/admin/ => 17 (17+0)
Grand total: 130
Bugs creator.
Features destroyer.
Template killer.

Re: The queries countdown

Reply #8

If I did the same search(s) I think its now

Controllers (75 / 12)
Admin (3 / 0)

Total of 90 !

but we need the master counter to verify  O:-)


Re: The queries countdown

Reply #10

I look forward to the awesome sauce !

Re: The queries countdown

Reply #11

Final count for 1.0 is:
controllers: 68 / 12
admin: 1 / 0
Total: 81.
Very good situation considering where we started! :D

The development branch is already at:
controllers: 47 / 0
admin: 0 / 0
So, just 47 queries in total!
Thanks to @groundup for his contributions to the task! :D (Or maybe it was at bringing back to controllers things that were not supposed to stay in subs... either way thanks. :P)
Last Edit: June 13, 2014, 05:00:53 pm by emanuele
Bugs creator.
Features destroyer.
Template killer.

Re: The queries countdown

Reply #12

Wow ... its all a blur now :P ... 1000+ knocked down to 81!  Awesome job everyone!

One other goal/objective in 1.1 would be to combine any duplicate/similar ones where it makes sense ... I know we have a few similar to one another in a few places,.  Just getting them out of the controllers was monumental task to start with, and I must say being able to use them in addons is a delight :D

Re: The queries countdown

Reply #13

oh, that's great :D
Thorsten "TE" Eurich
------------------------