开发者

Benefits of SPATIAL over using standard bounding box query

Benefits of SPATIAL over BOUNDING

What are the benefits of using a SPATIAL query rather than a simple MySQL query that utilised a bounding box?

For example, if I wanted to find开发者_如何学JAVA all locations that fall within a certain polygon:

Something like this:

Bounding Box Example

SELECT * FROM geoplaces 
WHERE geolat BETWEEN ? AND ?
AND geolng BETWEEN ? AND ?

As I understand, the only real benefit is that spatial will also factor in the earth's curvature?

Which method is fastest also?


Advantages:

  1. You can use shapes other than points and rectangles, and operations other than "is-in".
  2. If you can use SPATIAL indexes, performance is orders of magnitude better (depending of course on the size and nature of your data).

Disadvantages:

  1. Spatial objects are binary blobs - some care is needed handling them (e.g. you typically can't copy-paste a value).
  2. Spatial indexes in mySQL are only available for MyISAM tables.
  3. Support in mySQL is somewhat primitive; many operations are not implemented yet

If your database is large and you need searches like the one in your example to be fast, you should definitely go with SPATIAL indexes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜