How to Optimize Query?
Posted: Thu Mar 13, 2008 5:33 am
i got a query for creating a dynamicly ranks in my game but I think they are very 'slow'
$start - is for counting ranks
$nazwy - names of tables in base to search in
tables have indexes
little info$nazwy = array('points_fleet_old','points_tech_old','points_builds','points_builds2');
foreach($nazwy as $tab){
$tablica = $db->doquery("SELECT `id` FROM `users` ORDER BY `{$tab}` DESC");
$start = 1;
while($row = $tablica->fetch_array()){
if($row['id'] == $user['id']) {echo $tab.": palce".$start;}
++$start;
}
unset($tablica,$row);
}
$start - is for counting ranks
$nazwy - names of tables in base to search in
tables have indexes