[英]How can I check if a sql query is deterministic?
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.
确定性通常仅在谈论UDF时起作用。
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.
通常最好以星形或雪花模式的某种形式存储数据,如果需要的话,这可以简化多维数据集的生成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.