MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2012, 04:14 PM
jack13580 jack13580 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 132 jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level)jack13580 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 18 h 58 m 52 sec
Reputation Power: 75
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.

Reply With Quote
  #2  
Old November 5th, 2012, 07:09 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 6991
MySQL has special spatial indexing extensions that are specifically intended to index this type of data; I highly recommend looking into those (google "MySQL spatial") because this type of query will be very difficult to optimize in any other way.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Help making an sql query run faster

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap