Deterministic function in mysql

后端 未结 5 1505
野性不改
野性不改 2021-01-03 18:27

I got confused with a seemingly simple concept. Mysql defines deterministic function as a function that

always produces the same result for the same

5条回答
  •  星月不相逢
    2021-01-03 18:48

    DETERMINISTIC results does not refer to different results sets being returned at different times (depending on what data has been added in the mean time). Moreover it is a reference to the result sets on different machines using the same data. If for example, you have 2 machines which run a function including uuid() or referencing server variables then these should be considered NOT DETERMINISTIC. This is useful for example in replication because the function calls are stored in the binary log (master) and then also executed by the slave. For details and examples see http://dev.mysql.com/doc/refman/5.0/en/stored-programs-logging.html

    The use of DETERMINISTIC is thus (99% of the time) correct, not to be considered misuse.

提交回复
热议问题