If a function is deterministic for then it can be executed once and
its result can be memoized for the rest of the statement (or
transaction even).

If a function is idempotent for a statement then it can be executed
once per-statement, and its result(s) can be memoized and reused for
the life of that statement.

If a function is neither idempotent (even if it is deterministic in
the sense of not being random, for example, a monotonically increasing
counter) nor deterministic (e.g., a true random()) then it should be
called exactly as many times as the statement seems to imply, no more
and no fewer (e.g., once per-row of a correlated sub-query, ...).

Can idempotence and determinism be considered synonymous for the
purposes of an RDBMS engine?  I think not quite: deterministic should
imply that a memoization cache can be used always, across many
statements and even transactions, whereas idempotence might imply only
that memoization is permitted (but not required) on a per-statement
basis.

Another desirable attribute might be whether the function is fast or
slow: for fast enough deterministic functions there will be no point
in having a large memoization cache, or even any memoization cache.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to