Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 Computed Columns and Indexes

Author  Topic 

ferrethouse
Constraint Violating Yak Guru

352 Posts

Posted - 2015-01-28 : 18:01:50
Hi,

The following portion of a query is causing index scans...

AND (([Project5].[C1] = (DATEPART(dayofyear, [Extent6].[DateAdded])))

I presume this is always the case when the right side of the evaluation is a function. In order to overcome this I believe I should create a computed column with an index and then modify the query. Is this correct? My developers aren't sure if they can do this since they are using entity framework.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-01-28 : 18:26:23
It's the case when there are functions on an indexed column, so it doesn't matter if it's on the left side or right side. Yes, you can create a computed column to workaround this.

Don't even get me started on entity framework...

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -