Why is LINQ JOIN so much faster than linking with WHERE?

后端 未结 3 2184
我在风中等你
我在风中等你 2020-11-22 02:31

I\'ve recently upgraded to VS 2010 and am playing around with LINQ to Dataset. I have a strong typed dataset for Authorization that is in HttpCache of an ASP.NET WebApplicat

3条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 03:08

    The Join is much faster, because the method knows how to combine the tables to reduce the result to the relevant combinations. When you use Where to specify the relation, it has to create every possible combination, and then test the condition to see which combinations are relevant.

    The Join method can set up a hash table to use as an index to quicky zip two tables together, while the Where method runs after all the combinations are already created, so it can't use any tricks to reduce the combinations beforehand.

提交回复
热议问题