I'm using a view ("UsersActive") against my table ("Users"). The view has only one filter, it checks if DateTime Users.DeletedOn is NULL; it basically contains all Users that are not deleted.
If I now execute Linq queries against the view instead of the table, will they still use the table indexes or do I need to create special indexes for the view? In my understanding the View is nothing else but a predefined query and should work just as if I was querying this directly:
SELECT * FROM Users WHERE DeletedON = NULL
Is my assumption that the underlying table's indexes will still be used correct?
Most of the time, SQL Server Query Optimizer is smart enough to use the indexes on the base table. You can see this by looking at the query plans.
If you have enterprise edition of the SQL Server you can also use indexed views.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With