Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your question "would I experience a significant <strong>increase</strong> in speed ... [by] changing things over to using the geometry data type?" seemed to disregard the possibility that using the dedicated spatial datatypes could actually slow things down. Yet, this may actually be the case, for several reasons.</p> <p>Firstly, remember that the geometry and geography datatypes support not only points, but linestrings and polygons. The additional complexity they support means that they don't necessarily use simplistic point-to-point distance calculation. They also support a greater range of inbuilt functions on those types, so the serialized value of a point is more complex than just a set of lat, long coordinates. This means that a geometry/geography point value might be slower to retrieve and query than the equivalent columns of raw float coordinate data.</p> <p>The second, and more significant factor relates to the accuracy with which the distance calculation is performed:</p> <p>1.) If you have projected coordinates (i.e. UTM, National Grid, or State Plane) then coordinate values are measured in linear (x, y) units on a flat plane. Therefore it's easy to calculate the distance between two points using basic trigonometry: Dist(xy) = SQRT( (x2 - x1)2 + (y2 - y1)2 ) This is a simple mathematical method and you'll be unlikely to see much performance difference whether you implement this yourself or using the geometry datatype.</p> <p>2.) If you have geographic coordinates (i.e. Latitude/Longitude) then these are measured in angular units on an <em>ellipsoid</em>. Most commonly, this is the WGS84 ellipsoid as used by WGS84 systems. In many cases, you can get a good enough approximation of the distance between two points on the ellipsoid by using simple <em>spherical</em> calculations instead, as you do in your stored procedure. However, the shape of the earth more closely resembles a squished sphere - it's wider at the equator than it is high to the poles, and your calculation doesn't allow for this flattening of the earth. The geography datatype uses ellipsoidal calculations, based on the ellipsoid model of the supplied SRID, which are necessarily more complex, but will result in a more accurate answer.</p> <p>So I'd recommend that if you want to increase <em>precision</em> and <em>functionality</em> of your spatial data then you should move to spatial datatypes, but not for performance reasons.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload