我们最大的表有大约 7 条 Mio 记录。当我在 int 类型的非聚集索引上查询表时:
例如:
Select * from MyTable where TypeID = 401
-- 显示少于 147000 行大约需要 7 秒。
Select * from MyTable where TypeID like '%401%'
-- 显示少于 147000 行大约需要 13 秒。
有没有办法在这里提高性能?例如。更多内存?我们目前有 16GB。
我的表脚本:
create table MyTable (ID int not null, Description nvarchar(50) not null, TypeID int not null, primary key (ID));
create index MyTable_TypeID on MyTable (TypeID);
编辑:大部分答案都围绕第二个查询,实际上可以忽略。应该重点关注第一个查询。有什么办法可以更快地检索数据?