I was looking through the answers and decide to contribute a more compact and updated answer.
A deterministic function always return the same result given the same input parameters in the same state of the database. Eg POW,SUBSTR(),UCASE().
A non deterministic function does not necessarily always return the same result given the same input parameters in the same state of the database. Eg CURDATE(), RAND(), UUID().
MySQL 8.0 Reference Manual have some update on this
8.2.1.20 Function Call Optimization
MySQL functions are tagged internally as deterministic or nondeterministic. A function is nondeterministic if, given fixed values for its arguments, it can return different results for different invocations. Examples of nondeterministic functions: RAND(), UUID().If a function is tagged nondeterministic, a reference to it in a WHERE clause is evaluated for every row (when selecting from one table) or combination of rows (when selecting from a multiple-table join).MySQL also determines when to evaluate functions based on types of arguments, whether the arguments are table columns or constant values. A deterministic function that takes a table column as argument must be evaluated whenever that column changes value.
Nondeterministic functions may affect query performance. For example, some optimizations may not be available, or more locking might be required. The following discussion uses RAND() but applies to other nondeterministic functions as well.
This code example from MySQL 8.0 Reference Manual. You can create the table then populate the data with 49 rows like id column 1 to 49 and col_a some strings which are unique like "AA","AB","AC" until 49 rows. You can actually do 15 rows but you need to change the 49 to 15 that's more of topic of the random function.
CREATE TABLE t (id INT NOT NULL PRIMARY KEY, col_a VARCHAR(100));
SELECT * FROM t WHERE id = POW(1,2);
SELECT * FROM t WHERE id = FLOOR(1 + RAND() * 49);
The code will help illustrate the point, the MySQL 8.0 Reference manual is trying to make. Hopefully this helps thanks !
DETERMINISTIC
andREADS SQL DATA
at the same time (and what that would mean for the function). – Hagiographer