sql - LINQ Joins - Performance -


How am I keen on how to fix LINQ (LINQ to SQL), behind the scenes in relation to how SQL Server works.

SQL Server generates an execution plan before executing a query. The execution plan is basically an expression tree, which believes that the best way to execute the query is. Provides information about each node, sort, scan, select, join, act or not.

On our 'Join' node in our execution plan, we can see three possible algorithms; Join the hash, join, and join nested loop. SQL Server will select the algorithm for each encore based on the required number of rows in the inner and outer tables, how do we get involved (some algorithms do not support all types of joining), even if we order data , And maybe there are many other factors.

Join the Algorithm:

Join the Nested Loop: The best for short input, can be customized with the ordered inner table.

Join the merge: Best input from input medium for medium to large input, or ordering an output is required.

Join the hash: medium to large input, can be parallel to parallel scale.

LINQ query:

  Datatelle preTable, secondtable; ... var rows = first in line first OtherMairable () Join the second line in the second.Table. First equals () at firstRow Field & lt; Object & gt; (Random object. Property) equals 2nd Row.Field & lt; Object & gt; (RandomObject.Property) Select New {firstRow, secondRow};  

SQL query:

from