Let's say I have a table of 2D points (geographical coordinates) in database. What is a best practice to organize the data to make search a row with most closest coordinates to the given among this array of data?
I cannot figure out anything better than:
SELECT * FROM `pois` WHERE 1
ORDER BY ($x-`x`)*($x-`x`) + ($y-`y`)*($y-`y`) ASC LIMIT 1
This approach can be acceptable if the table size is 1000 rows. But it can be terribly slow if the poi
DB is 1 million of rows...
Any thoughts?