Actions

Talk

Developer Area/How to Review Code: Difference between revisions

From Mahara Wiki

(Created page with "Hi, I am a bit confused as to what a 'si query' is in the line: 'Watch out for queries inside loops (do it outside the loop all at once in a si query)' . I have tried several …")
 
No edit summary
Line 6: Line 6:


Kevin
Kevin
:That's a typo. It should say "in a single query". As in, rather than doing a loop over the ids (1,2,3,5) in which you do "select owner from view where id=?" four times, it's more efficient to do one query, "select owner from view where id in (1,2,3,5)" and then loop over the results. Although in practice, this kind of optimization only tends to have a noticeable effect on "bulk" pages where you're processing at least 100 of something.
:Also, you'll probably get a quicker response if you post your questions in the mahara.org forums, or our IRC channel, #mahara-dev or freenode. --[[User:Aaronw|aaronw]] 22:05, 14 July 2013 (UTC)

Revision as of 11:05, 15 July 2013

Hi,

I am a bit confused as to what a 'si query' is in the line: 'Watch out for queries inside loops (do it outside the loop all at once in a si query)' .

I have tried several searches but have drawn a blank.

Kevin

That's a typo. It should say "in a single query". As in, rather than doing a loop over the ids (1,2,3,5) in which you do "select owner from view where id=?" four times, it's more efficient to do one query, "select owner from view where id in (1,2,3,5)" and then loop over the results. Although in practice, this kind of optimization only tends to have a noticeable effect on "bulk" pages where you're processing at least 100 of something.
Also, you'll probably get a quicker response if you post your questions in the mahara.org forums, or our IRC channel, #mahara-dev or freenode. --aaronw 22:05, 14 July 2013 (UTC)