MySQL-Performance when ordering on calculated column

后端 未结 2 1066
傲寒
傲寒 2021-01-23 17:08

Given is a table with 300\'000 test-records.

I need to do a select like this:

SELECT (SQRT(POWER(ABS(posts.latitude-$lat),2)+POWER(ABS(posts.longitude-$l         


        
2条回答
  •  广开言路
    2021-01-23 17:28

    Make the column for $userParam an index, that way the query will perform faster. Or you could create an indexed view: http://www.codeproject.com/Articles/199058/SQL-Server-Indexed-Views-Speed-Up-Your-Select-Quer

    Hope this helps

提交回复
热议问题