Sql 如何为此表构建索引/优化
我使用的是SQLServer2008R2,我的数据库中有一个类似这样的表Sql 如何为此表构建索引/优化,sql,sql-server,database,database-design,Sql,Sql Server,Database,Database Design,我使用的是SQLServer2008R2,我的数据库中有一个类似这样的表 Id (Int), Name(NVarChar), DateCreated(DateTime), Message(NVarChar) 仅对该数据库表运行3个查询 select top 1 * from table1 where Name = @input // almost all Names are unique, used 55% of the time select top 100 from table
Id (Int), Name(NVarChar), DateCreated(DateTime), Message(NVarChar)
仅对该数据库表运行3个查询
select top 1 *
from table1
where Name = @input // almost all Names are unique, used 55% of the time
select top 100
from table1
where DateCreated > @input // used 40% of the time
insert... //create new record, used 5% of the time
这个表有超过2000万行
如何优化此数据库?在Name和DateCreated上添加索引我该怎么做?我是数据库设计新手,从未使用过sql server 2008,但这应该可以做到:在表1(名称)上创建索引名称\索引;创建索引日期\表1上的索引(DateCreated);在这里阅读更多