Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

Computed Column in the include of a Non Clustered Index not working as expected

$
0
0

Hello,

I have a table with a text field containing up to 30k characters. Since I cannot use this field in the include of my indexes I have created a persisted computed column that cuts down to total length to a varchar(8000) and added this column to the include of my index.

My questions is, why don't my queries use the non clustered index and always go for the clustered index?

My index is partitioned and has the following structure:

CREATE NON CLUSTERED INDEX [XPTO] ON [TABLE1] (ID_COL ASC) INCLUDE (BIG_VARCHAR_COL) ON PART_SCH(PARTITION_COL)

My select is something like:

SELECT ID_COL, BIG_VARCHAR_COL FROM TABLE1 WHERE ID_COL='XPTO' AND PARTITION_COL=123

and my execution plan don't use the NC Index and instead uses the Clustered Index plus 2x Compute Scalar.

Why is this happening?


Luis Simões


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>