Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. 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

We currently store points as three floats (lat,lon,alt) and support only one type of query (points within a given radius) but look forward to support more queries. We are using PHP and MySQL.

What are the benefits of using geospatial types?

share|improve this question
up vote 5 down vote accepted

The spatial datatypes are in return for only supporting one type of query, much much faster at that type of query. Consider importing something like the MaxMind Cities database and finding the city closest to you. With regular float datatypes, that query would need to check all 2.7 million records against eachother to find the closest one (calculate haversine distance of every point to every other point). The Geospatial types on the other hand can be queried for the closest point and will be orders of magnitude faster by using something like quad-trees for the internal representation of the index.

You can do some logic to make querying with regular keys faster, described in this presentation among others. But this is no longer necessary since geospatial indexes are much better at this task.

share|improve this answer

Take a look at this wikipedia article on spatial databases

Especially the section "Features of spatial databases"

The types of queries presented there is what you can do with spatially enabled data. Spatially enabled data have extra "dimensions" by which they can be queried on that regular data cannot.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Thomas Owens Jun 20 '12 at 15:01
also could be helpful if you mention specifics for MySQL – nischayn22 Jun 20 '12 at 15:29

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.