Filtered index condition is ignored by optimizer

前端 未结 3 1630
礼貌的吻别
礼貌的吻别 2020-12-06 09:43

Assume I\'m running a website that shows funny cat pictures. I have a table called CatPictures with the columns Filename, Awesomeness,

3条回答
  •  遥遥无期
    2020-12-06 10:26

    No, not currently.

    See this connect item. It is Closed as Won't Fix. (Or this one for the IS NULL case specifically)

    The connect item does provide a workaround shown below.

    Posted by RichardB CFCU on 29/09/2011 at 9:15 AM

    A workaround is to INCLUDE the column that is being filtered on.

    Example:

    CREATE NONCLUSTERED INDEX [idx_FilteredKey1] ON [dbo].[TABLE] 
    (
        [TABLE_ID] ASC,
        [TABLE_ID2] ASC
    )
    INCLUDE ( [REMOVAL_TIMESTAMP]) --explicitly include the column here
    WHERE ([REMOVAL_TIMESTAMP] IS NULL)
    

提交回复
热议问题