i've got query loaded everytime user open profile page. , slow. takes more 20 seconds load page. kinda simple query, alot of lines don't scared looking @ it. :) i appericiate on improving query. select `h`.`login` `login`, sum(if(((`h`.`cmd` = 0) or (`h`.`cmd` = 1)),`h`.`pips`,null)) `total_pips`, count(if(((`h`.`cmd` = 0) or (`h`.`cmd` = 1)),`h`.`position_num`,null)) `total_trades`, (count(if(((`h`.`pl` > 0) , ((`h`.`cmd` = 0) or (`h`.`cmd` = 1))),`h`.`pl`,null)) / count(if(((`h`.`cmd` = 0) or (`h`.`cmd` = 1)),`h`.`position_num`,null))) `winning_trades_percent`, sum(if(((`h`.`cmd` = 0) or (`h`.`cmd` = 1)),`h`.`gain`,null)) `total_gain`, (select avg(`wg`.`weekly_gain_all`) `gt_view_weekly_gain` `wg` (`wg`.`login` = `h`.`login`) group `wg`.`login`) `weekly_gain`, avg(if(((`h`.`pips` > 0) , ((`h`.`cmd` = 0) or (`h`.`cmd` = 1))),`h`.`pips`,null)) `average_profit_pips`, avg(if(((`h`.`pips` <= 0) , ((`h`.`cmd` = 0) or (`h`.`cmd` = 1)...