之间有什么区别CREATE INDEX和CREATE STATISTICS何时该使用的呢?
我正在考虑一种情况,我有两个高密度的列,但这些列不是独立的。
这是我为测试目的而创建的表的定义。
CREATE TABLE [dbo].[StatsTest](
[col1] [int] NOT NULL, --can take values 1 and 2 only
[col2] [int] NOT NULL, --can take integer values from 1 to 4 only
[col3] [int] NOT NULL, --integer. it has not relevance just to ensure that each row is different
[col4] AS ((10)*[col1]+[col2]) --a computed column ensuring that if two rows have different values in col1 or col2 have different values in col4
) ON [PRIMARY]
Run Code Online (Sandbox Code Playgroud)
实验数据如下
col1 col2 col3 col4
1 …Run Code Online (Sandbox Code Playgroud)