Shop表存储字段 Lat, Lng
It is now time to use the scheme to page through the calculation of the distance from the SQL statement order by limit
but to calculate it within SQL, resulting in a slow query.
There are currently two options
A方案 :
The front end through the interface to obtain data for paging, using the above two scenarios, is a one-time pull out the data of nearby merchants, then the distance calculation, based on the distance of the order to generate the final array, the data paging should be based on the index of the array to calculate the offset of the paging operation?
Do you have better algorithms for nearby businesses + pagination?
Supplement also requires the ability to search by city and region
Reply content:
Shop表存储字段 Lat, Lng
It is now time to use the scheme to page through the calculation of the distance from the SQL statement order by limit
but to calculate it within SQL, resulting in a slow query.
There are currently two options
A方案 :
The front end through the interface to obtain data for paging, using the above two scenarios, is a one-time pull out the data of nearby merchants, then the distance calculation, based on the distance of the order to generate the final array, the data paging should be based on the index of the array to calculate the offset of the paging operation?
Do you have better algorithms for nearby businesses + pagination?
Supplement also requires the ability to search by city and region
With a relational database, add an index to the latitude-longitude. Near the algorithm can start from the latitude and longitude, with the user's latitude and longitude (x, y) as the benchmark, the scope of the query ((x+/-), Y (+/-)), expand the scope of the search is the X y range of increased.
Use Elasticsearch or SOLR-like search engines that support space.
Previously written about Demo:django ElasticSearch Ionic building a GIS mobile application-Architecture design