Tag Info

New answers tagged


You may have better performance if you convert the function into a table-valued-function. Here, I setup the test-bed: USE tempdb; CREATE TABLE dbo.TableA ( LAT DECIMAL(10,5) , LON DECIMAL(10,5) ); CREATE TABLE TableB ( Geolocation GEOGRAPHY NOT NULL ); GO Here is the table-valued-function, which is basically your function except this returns ...


Best use ST_DWithin() in a LATERAL join: SELECT t.*, neighbor.* -- or only selected columns FROM tbl t LEFT JOIN LATERAL ( SELECT * FROM tbl t1 WHERE ST_DWithin(t.geo_point, t1.geo_point, 5000 * 1.609344) ) neighbor ON true WHERE t.address = 'my_address'; -- to restrict to a particular address 1.609344 being the factor for converting ...

Top 50 recent answers are included