I want to notice the results of a function for performance, i.e. lazily populating a cache indexed by function arguments. The first time I call a function, the cache will not have anything for the input arguments, so it will compute it and save it before returning. Subsequent calls simply use the cache.
However, it seems that SQL Server 2000 has a silly arbitrary rule that functions are "deterministic." INSERT, UPDATE, and regular stored procedure calls are not allowed. However, extended stored procedures are allowed. How is it determined? If another session changes the state of the database, the output of the function will change in any case.
I got angry. I thought I could make caching transparent to the user. Is it possible? I do not have permissions to deploy extended stored procedures.
EDIT:
This is a limitation back in 2008. You can't call RAND, for God's sake!
The cache will be implemented by me in the database. A cache is any data store used for caching ...
EDIT:
There are no cases where the same function arguments will give different results outside of changes in the underlying data. This is a BI platform, and the only changes come from the planned ETL, and at this time I would TRUNCATE in the cache table.
These are intensive calculations of time series of input-output, order O (n ^ 4). I have no mandate to change the underlying table or indexes. In addition, many of these functions use the same intermediate functions, and caching allows you to use these functions.
UDFs are not truly deterministic unless they take into account changes in the state of the database. What is the point? Is SQL Server Caching? (Ironic.) If SQL Server is cached, it should expire when tables bound to a schema change. If they are related to a schema, then why not bind the tables that the function modifies? I see why procs are not allowed, although this is just messy; just a circuit bundles procs. And, BTW, why allow extended stored procedures? You cannot keep track of what they are doing to ensure determinism !!! Argh !!!
EDIT:
My question is: is there a way to lazy cache result in a way that can be used in a view?
caching sql-server sql-server-2000
alyssackwan
source share