1

If just to determine whether a point is within a rectangle,

What is wrong with this query? EXPLAIN SELECT DISTINCT TB.ID, TB.Latitude, TB.Longitude FROM TableBusiness AS TB

WHERE -6.2317830813328 < TB.Latitude AND TB.Latitude < -6.1382169186672 AND TB.FoursquarePeopleCount >5 AND 106.72621691867 < TB.Longitude AND TB.Longitude <106.81978308133 LIMIT 0, 20

It seems that normal index would do fine. After all TB.Latitude and TB.Longitude is indexed.

But then I want to do something more complicated like nearest neighbor search.

Then somebody says that even with spatial index I can't do that. I have to start with a small rectangle, find all points within that rectangle, and then see if I got 20 points, if not, make the rectangle bigger.

If I have to go through all that, why do I need spatial index?

So what's the point of having spatial index?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.