![]() Topic awaiting preservation: improving speed of mysql distance filter (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: Careywood, Idaho, USA |
![]() Hello! code: SELECT {fields}, SQRT( (69.1 * ('48.055621' - a.lat)) * (69.1 * ('48.055621' - a.lat)) + (53.0 *('-116.585400' - a.lon)) * (53.0 *('-116.585400' - a.lon))) as distance FROM {tables} WHERE {criteria} HAVING distance < '{distance}' ORDER BY distance ASC
code: WHERE a.lat > a.lat - '{X}' AND a.lat < a.lat + '{X}' a.lon > a.lon - '{X}' AND a.lon < a.lon + '{X}' {criteria}
|
Maniac (V) Inmate From: Sthlm, Sweden |
![]() check the FAQ: http://www.ozoneasylum.com/21781 |
Nervous Wreck (II) Inmate From: Careywood, Idaho, USA |
![]() DmS: |
Maniac (V) Inmate From: Sthlm, Sweden |
![]() Well, not being an sql-guru myself I can't really judge the query. |
Nervous Wreck (II) Inmate From: Careywood, Idaho, USA |
![]() Thanks! |
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() also, I suggest you read up on mysql->explain and then do an explain your_query, to see if there's something that mysql itself suggests to speed your query up. |
Nervous Wreck (II) Inmate From: Careywood, Idaho, USA |
![]() Still no replies to my thread at http://forums.mysql.com/read.php?115,91048. |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
![]() I would store the results of each request in a column of the record. That way you can check the result column to see if it is empty and then do the calculation. If the calculation has already been done once, return the result. This means the request will be slow only the first time you make a request for a given zip-code. |