I'm trying to get points around "me" by location and it's pretty simple :
select * from X where ((SQRT(POW(69.1 * (a.lat - 49.201441 ), 2) +
POW(69.1 * (16.161299 - a.lng) * COS(a.lat / 57.3), 2))) <='1') LIMIT 5
*
my location = 49.201441;16.161299
distance = 1 (mile)
This query returns me 5 points around "me" at a distance of 1 mile. This is rly fast, but just when my table have a ... I don't know, maybe 5000 rows.
I'm using this query on 200 000 rows table, and it's very slow! Maybe .. 2-7 sec and even if the limit is 1 = no difference.
Can someone explain it to me and help me? Thanks a lot guys!
BTW: If my query does not contains this part of query = it takes maybe 0.0008s... so second part of query is correct.