Here is a short experiment to see what happens.
create function determin_rand (i integer)
returns float DETERMINISTIC
return rand();
create function not_determin_rand (i integer)
returns float
return rand();
select determin_rand(1) as d1 , determin_rand(1) as d2,
not_determin_rand(1) as nd1, not_determin_rand(1) as nd2
0.00850549154 0.831901073456 0.133989050984 0.174242004752
Since the values are different, the function is called every time. In the first function, I declared it deterministic, but it did not matter.
I made sqlfiddle for you to try it with different versions of mysql.
http://sqlfiddle.com/#!2/a8536/2
source
share