mysql - Will a function will be recalled when I use its alias in ORDER BY clause? -


here simplified version of query:

select myfunc(u.id) score users u order score limit 20 

as see, i've used score (which result of myfunc() function) in order by clause. want know, function recalled when use in order by clause? if yes, how can avoid that? because function needs lots of processing , recalling twice nightmare.

probably not, because data has been prepared time ordering done. if still have doubt, test making function visible between runs (increment value in table)

what may find though, runs million times, once each of million rows, before limit 20 can applied..

if function slow, , sensible store result upon insert rather calculate every time query run, that


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -