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?
|
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? |
|||
|
|
|
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. |
|||
|
|
|
Take a look at this wikipedia article on spatial databases http://en.wikipedia.org/wiki/Spatial_database 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. |
|||||||
|