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:
Does not send signals included in SQL Server from Linux Thus, the appearance of joining SQL using Linux will be similar to the performance of "directly" (either using a pure ADO or SQL Server Management Studio) on the server without any identical identification.
Link to SQL also allow Allow to use connecting signals (as far as I know). So if you want to be compelled to join a particular type, then you have it stored in a stored procedure or [order | Question]
method but unless you have INNER [HASH | LOOP | MERGE] do not specify an insert type by typing JOIN
, then SQL Server always tries to join the type that thinks it will be the most efficient - it does not matter where the query is from Was there.
Other link query providers - such as the unit framework and NHibernate Linq - will do the same thing as Linq to SQL. None of these have direct knowledge about how you have indexed your database and therefore none of them sends signals to join.
The link for objects is slightly different - this is about (almost?) Always "joining the hash SQL server language" The reason is that there is a marked lack of indexing needed to merge in it, Em> Typically is more efficient than the nested loop, unless the number of elements is too small. But IEnumerable & lt; T & gt; In order to determine the number of elements in the first place, a full trend may be required, so in most cases it may be the fastest and use a hashing algorithm.
Comments
Post a Comment