Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.