Optimization on Nested Loop |
I have some concerns on Nested loop with sub query for example i have a main query that states like this
$main_query = "select fname,lname,dept from employee AS e INNER JOIN dept AS d on d.emp_id = e.emp_id" foreach($main_query as $val): then adding some query loops like $sub_query = select sum(users) as total from assignees where emp_id = {$val->emp_id} echo $sub_query ? $sub_query->total : "0"; endforeach; is this a bad habit? My fix for this was to create and array on all assignments then loading it once then on the forloop i just called the array and check if its equal then i'll get the data on it? is this the best approach? |
Messages In This Thread |
Optimization on Nested Loop - by codeigniter_guru - 11-10-2017, 01:55 AM
RE: Optimization on Nested Loop - by Narf - 11-10-2017, 04:31 AM
RE: Optimization on Nested Loop - by PaulD - 11-10-2017, 04:36 AM
RE: Optimization on Nested Loop - by Narf - 11-10-2017, 06:19 AM
RE: Optimization on Nested Loop - by averroez - 11-14-2017, 12:23 AM
RE: Optimization on Nested Loop - by codeigniter_guru - 12-18-2017, 01:13 AM
RE: Optimization on Nested Loop - by Shawn - 12-22-2017, 03:04 PM
RE: Optimization on Nested Loop - by rolly - 12-24-2017, 02:45 PM
|