Geolocating the Nearest Pub

Learn about kNN search and indexing in kNN search.

kNN search

To implement a kNN search in PostgreSQL, we need to order the result set with a distance operator, written <->. Here’s the full SQL for searching the pubs near a known position:

Get hands-on with 1200+ tech skills courses.