0

I came across this set of symbols in an Advanced SQL (postgresql) course video by Torsten Grust: https://youtu.be/WPhU74hmtRw?t=1197

It is in the ORDER BY portion of the query: ORDER BY p.point, p.loc <-> k.mean) AS assign

He explains the meaning, "the minimum distance between one point from another", and I have looked for documentation or other samples, but could not find any. Can anyone point me in the right direction?

1 Answer 1

3

the <-> operator in postgresql is a custom operator defined by the PostGIS extension, see it's documentation. Basically:

The <-> operator returns the 2D distance between two geometries. Used in the "ORDER BY" clause provides index-assisted nearest-neighbor result sets. For PostgreSQL below 9.5 only gives centroid distance of bounding boxes and for PostgreSQL 9.5+, does true KNN distance search giving true distance between geometries, and distance sphere for geographies.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the quick answer. Super helpful docs, I'm really not sure why my searches didn't turn up the operator. Maybe the characters caused issues in the search engine.
@dannylee8 It's not specific to PostGIS. <-> is also available for geometric types and for full text search
@a_horse_with_no_name -Thank you, great links! I have a ton to explore.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.