views:

56

answers:

2

Does LINQ2SQL make use of table indexes when executing a query?

+7  A: 

Database table indexes are used by the database itself when compiling an execution plan for the SQL that LINQ2SQL gives it to execute. It's hidden completely from LINQ2SQL, which itself goes via ADO.NET for database access.

So the simple answer is, yes, LINQ2SQL uses table indexes, but only by default because the database itself uses them.

Ash Eldritch
+1  A: 

LINQ2SQL will create the appropriate SQL then hand that to the MS-SQL server for execution. The server will then use the indexes to speed up the query.

It might be interesting to know if LING2SQL considers the indexes when building the query.

lexu