I found this question and am wondering, is it for PostgreSQL? Where’s the documentation for <->
? Trying to find the fastest way to get the distance between a lat and long earth coordinates in Redshift.
1 Answer
You'll find an exhaustive overview of supported operators in the PostGIS Function reference under Operators.
The more or less canonically named spatial (K)NN operator <->
is documented under Distance operators.
Note that this is an extension to the core distance operator shipped with PostgreSQL. This and its sibling operators are implemented with conditional access a to a suitable index (supporting (K)NN traversal) if put into the ORDER BY
clause - and only this implementation detail is the primary performance advantage over plain distance functions!
For spatial distances in the PostGIS extension environment, the operator either returns 2D cartesian distances (GEOMETRY
) or spherical (great-circle) distances (GEOGRAPHY
).