我有一张存放笔记的桌子
create tblNote(
Id int identity(1,1),
ParentId int ,
ParentType varchar(32),
NoteType varchar(32),
Note varchar(max),
CreatedBy varchar(25),
CreatedDate datetime,
.
.
.
<other metadata about the note>
)
Run Code Online (Sandbox Code Playgroud)
我最近阅读了很多关于 MSSS 如何处理索引(2005 年及以后)的文章。
我在 ID 上有一个聚集索引
[我已经考虑将聚集索引更改为 parentId、parentType,因为它相当狭窄并且是静态的。]
针对该表的绝大多数查询将遵循
select NOTE, createdDate, createdBy
from tblNote
where parentId = 12 and parentType = 'RFQ'
Run Code Online (Sandbox Code Playgroud)
我今天想问的问题(尽管欢迎任何反馈)是这样的:
我可以添加的 NC 索引是:
create index idx_nc_note_parent(
parentId ,
parenttype
)
include (createdby, createdDate)
Run Code Online (Sandbox Code Playgroud)
这对于创建小笔记列表很有用,我们可能会在其中包含谁和何时键入信息。
我很犹豫要不要包括一个varchar(max)
领域。看起来它真的会伤害将被缓存的索引量(这是合理的还是不合理的)
假设我不包含该NOTE
字段,则需要 RID 查找才能在需要时实际获取笔记内容。
虽然我已经阅读了很多关于 RID 查找有多昂贵的信息,但与进行表扫描相比,拥有此索引仍然必须更好,对吗?
[为代码块道歉,我添加了 4 …
sql-server ×1