0
I was studying geometric types and coordinates in SQL, in Postgresql more specifically, and I came across two operators, the operator <@> and the operator <->. What’s the difference between them? What’s the fastest?
0
I was studying geometric types and coordinates in SQL, in Postgresql more specifically, and I came across two operators, the operator <@> and the operator <->. What’s the difference between them? What’s the fastest?
1
The operator <->
(distance between 2 objects), defined in Postgresql itself, is used with objects of a two-dimensional space.
The operator <@>
(point <@> point), defined in the extra module "earthdistance", is used for the calculation of distances on the earth’s surface and takes into account the latitude and longitude of the points.
Browser other questions tagged sql postgresql
You are not signed in. Login or sign up in order to post.
The distance from the surface of the earth cannot be considered a two-dimensional space at the end of the day we use X and Y (lat lng)? From what I saw the <-> works with Point too, so which two methods would be the fastest?
– Eduardo Mior
According to the Terraplanists, yes.
– anonimo
It is that in the case of the Point we are not considering the altitude, only the latitude and longitude, then and if we put the earth in a straight plane it becomes a two-dimensional space, or the latitude and longitude cannot be considered as X and Y ?
– Eduardo Mior
The "earthdistance" module takes into account the curvature of the earth’s surface. Just remember that it is an approximation (consider the Earth as a perfect sphere), if you need more accuracy evaluate the use of Postgis.
– anonimo
In my case I need more optimization than precision, the accuracy for me is not important, I did some benchmarks comparing both Postgis and others and ended up not being very happy in the results, So in search of more agile solutions I ended up finding the distance operators, but I couldn’t find many explanations to tell the exact difference between them, all the documentation said was that they returned the distance between 2 points, but now it makes more sense. What I need is just sort by the nearest ones so I also don’t care about the unit of measure.
– Eduardo Mior