Let's start with the cos query itself (radians (geoname.latitude)) and other functions seem invariant, so we can do a little preprocessing and save the calculated values ββin a table. (Calculation of trigger functions is mainly due to the use of an expensive extension of the series).
6371 * acos (cos (radians (38.7666667)) - this is equal to radians (38.76667) * 6371, so why are we standing there.
Secondly, if you do not care, then what about accuracy. You can provide the radians themselves to say 10,000 points from 0 to pi / 2, which should give a good approximation, up to 4 decimal numbers, for example, less than a kilometer
(6371 * acos(cos(radians(38.7666667)) * cos(radians(geoname.latitude)) * cos(radians(geoname.longitude) - radians(-3.3833333)) + sin(radians(38.7666667)) * sin(radians(geoname.latitude))))
also remember that sin (a) when a> pi / 2 and a <pi is equal to sin (pi - a) when a> pi and a <3/2 pi is equal to -sin (a-pi) and when a> 3 / 2 pi and a <2pi is equal to -sin (2pi-a). Similar functions can be performed for the cos function.
Try it and see if it helps. Luke
source share