on 2009 Dec 10 8:25 PM
From the online books:
User-defined functions are treated as deterministic unless they are specified as NOT DETERMINISTIC when created.
We have some functions that look things up in the database, and seem to work correctly. So I would be really surprised if this is true.
Yes, Jon, they do. Unless the function is declared as NOT DETERMINISTIC
, the server is free to cache prior executions and re-use the results if the function is called again with the same parameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As Breck indicated, "free to cache" means that the server may (or may not) re-execute the UDF when another invocation of the function is made with the same parameters. The server maintains an LRU cache of function parameters and the function's result, and will perform a look-aside into the cache before it goes to the effort of creating a new procedure context and re-executing the procedure.
If you label a UDF as NOT DETERMINISTIC
, then we offer the guarantee that if the function is part of the query's SELECT
list, the function will be executed at least once for every row produced by the query.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.