"The best you can do is find a cunning way to crunch the numbers faster - by disregarding bits of data that you know aren't relevant, for instance, or by using a parallel-processing system, or by using a heuristic algorithm that gives a slightly less (but still acceptably) accurate solution with a significantly smaller amount of work."
Or..
You could use a different database paradigm entirely - drop the row/column stuff and use sparse arrays where the coordinates are the subscripts, and the search (assuming the longitude/latitude restrictions are still being used) becomes a matter of:
(apologies for the '.'s - quickest way I could think of to get some manner of indentation)
set long=startLong
for {
....set long=$next(destinationList(long))
....if long>endLong quit
....set lang=startLang
....for {
........set lang=$next(destinationList(long,lang))
........if lang>endLang quit
........if $$howfar(long,lang,userLong,userLang)<maxDistance {
............set resultList(distance)=destinationList(long,lang)
........}
....}
}
then just go through the resultList array, picking out as many as you need... self indexing, simpler, quicker, and a whole long easier to debug...