有一个表名为: BbsReply 字段如下
ReplyID int not null, -- 回复编号(自动增加1)
TopicID int not null, -- 主题编号
States tinyint not null, -- 状态 0,删除,1,锁定,2,有效
UserID varchar(20) not null,
Content text not null,
IntoTime datetime not null不是很频率的修改,主要使用搜索SQL如下:
Select * From ZtBBSReply Where TopicID=12345678 and States>0 Order By ReplyID ASC
我设了如下索引方案:
1、ReplyID和TopicID同时为关键字段,都为聚集索引
2、ReplyID为关键字段,TopicID建立为聚集索引
3、ReplyID为关键字段,ReplyID和TopicID同时设为聚集索引请问下各位大侠这样行不行,或有什么问题
ReplyID int not null, -- 回复编号(自动增加1)
TopicID int not null, -- 主题编号
States tinyint not null, -- 状态 0,删除,1,锁定,2,有效
UserID varchar(20) not null,
Content text not null,
IntoTime datetime not null不是很频率的修改,主要使用搜索SQL如下:
Select * From ZtBBSReply Where TopicID=12345678 and States>0 Order By ReplyID ASC
我设了如下索引方案:
1、ReplyID和TopicID同时为关键字段,都为聚集索引
2、ReplyID为关键字段,TopicID建立为聚集索引
3、ReplyID为关键字段,ReplyID和TopicID同时设为聚集索引请问下各位大侠这样行不行,或有什么问题
2.如果不是很频繁,数据量比较大,对ReplyID+TopicID建立联合主键,对ReplyID+TopicID建立聚集索引.
3.如果不是很频繁,数据量很大,则对可能针对某字段或某些字段出现的查询,建立视图.