i have a big problem with my database..
I need a very fast query over 2 tables.
1. table: (node) ~42.500.000 entrys
2. table: (waynode ~51.200.000 entrys
The following query is much to slow:
SELECT `node`.ID,`node`.LATITUDE,`node`.LONGITUDE,`waynode`.WAYID
FROM `node`, `waynode`
WHERE `node`.ID= `waynode`.NODEID
AND `node`.LATITUDE BETWEEN '49.558' AND '49.568'
AND `node`.LONGITUDE BETWEEN '11.3395' AND '11.3495'
ORDER BY `waynode`.WAYID
The current time is over 180 seconds..
I also have a INDEX over 2 columns created with ALTER TABLE node ADD INDEX (LATITUDE, LONGITUDE). When i am using the following select, it's very fast:
SELECT `node`.ID,`node`.LATITUDE,`node`.LONGITUDE
FROM `node`
WHERE `node`.LATITUDE BETWEEN '49.558' AND '49.568'
AND `node`.LONGITUDE BETWEEN '11.3395' AND '11.3495'
But I need the waynode
.NODEID like in the first SQL-Statement.
May someone help me please?
best regards
Ingo
Best Answer
See if this runs faster:
This might also work 'fast':
For further discussion, please provide
EXPLAIN SELECT ...
for any query you want to discuss andSHOW CREATE TABLE ...
for the tables in question.