
November 5th, 2012, 04:14 PM
|
|
|
|
Help making an sql query run faster
I have a database which could potentially hold up to a maximum of 140,000 records and need to display all of these records which of course is very resource extensive
also I have javascript and css and images which are making it even slower and all I have right now is 100 records and it takes up to 2 mins to load
this is the sql I use
I am using php for this as this is a webgame im making
PHP Code:
$sql = "SELECT users.username as owner , cities.name as town ,cities.CorX as x,cities.CorY as y,cities.points as points, cities.picture as picture ".
"FROM users INNER JOIN cities ON(users.username = cities.owner) ".
"WHERE cities.CorX BETWEEN ".$startX." AND ".$endX." ".
"AND cities.CorY BETWEEN ".$startY." AND ".$endY ." ";
$sql = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($sql)){
$mapArray[$row['y']][$row['x']] = array(
'owner' => $row['owner'],
'townname'=> $row['town'],
'points'=>$row['points'],
'picture'=>$row['picture']
);
}
could anyone help me figure out how to get this query to run faster?
you can see an example of this here but with this there's only 5 records in the database
http://the-test.comoj.com/map/test_map4.php
this doesn't work perfectly because for some odd reason only IE7+ is recognizing my z-index rules while chrome safari and firefox are ignoring it which makes the world map for my game usless
Last edited by jack13580 : November 5th, 2012 at 08:29 PM.
|