开发者

How can I check if a sql query is deterministic?

开发者 https://www.devze.com 2023-01-06 14:11 出处:网络
What I mean by deterministic is that the query will always return 开发者_开发知识库exactly the same result set.Is there a way to do this?Queries aren\'t typically considered to be deterministic as the

What I mean by deterministic is that the query will always return 开发者_开发知识库exactly the same result set. Is there a way to do this?


Queries aren't typically considered to be deterministic as the underlying tables can change between invocations. Determinism typically only comes into play when talking about UDFs.


The only way I know of to produce deterministic data in a database is to create a snapshot of the necessary data at the appropriate point in time. Usually, data is transformed and loaded into a data warehouse, along with a timestamp for the rows being archived, for later retrieval. Auditing and other kinds of reporting queries may be run against the data warehouse, and the results are "deterministic" for any given time period, but not across time periods.

Information housed in a data warehouse may also be precomputed into a multi-dimensional cube for faster processing, if necessary. To maintain proper form, data warehouse tables should only ever be inserted into, and new batches of data should always be associated with a unique timestamp. It is usually best to store data in some form of star or snowflake schema, which facilitates generation of a cube if necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消