I haven't done any SQL programming since around 1994, however I'd make the following observations:
- The formula that you're using is a formula that works as long as the distances between your coordinates doesn't get too big. It'll have big errors for working out the distance between e.g. New York and Singapore, but for working out the distance between New York and Boston it should be fine to within 100m.
- I don't think there's any approximation formula that would be faster, however I can see some minor implementation improvements that might speed it up such as (1) why do you bother to assign @l_lat_start from @lat_start, can't you just use @lat_start directly (and same for @long_start, @lat_end, @long_end), (2) Instead of having 111 in the formulas for @l_y_diff and @l_x_diff, you could get rid of it there hence saving a multiplication, and instead of 1000 in the formula for @l_distance_m you could have 111000, (3) using COS(RADIANS(@l_lat_end)) or COS(RADIANS(@l_lat_start)) won't degrade the accuracy as long as the points aren't too far away, or if the points are all within the same city you could just work out the cosine of any point in the city