<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>L2SProf</title>
        <link>http://ayende.com/Blog/category/560.aspx</link>
        <description>L2SProf</description>
        <language>en-US</language>
        <copyright>Ayende Rahien</copyright>
        <managingEditor>Ayende@ayende.com</managingEditor>
        <generator>Subtext Version 2.0.0.0</generator>
        <item>
            <title>Profiler new feature: Too many joins detection</title>
            <link>http://ayende.com/Blog/archive/2010/02/24/profiler-new-feature-too-many-joins-detection.aspx</link>
            <description>&lt;p&gt;This is &lt;a href="http://grahamis.com/blog/"&gt;Josh&lt;/a&gt;’s feature, since we wrote most of the code for it together. Basically, it recognize a very common performance problem, queries that uses too many joins, such as this one:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureToomanyjoinsdetection_1437B/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureToomanyjoinsdetection_1437B/image_thumb.png" width="329" height="301" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Which would result in the following warning:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureToomanyjoinsdetection_1437B/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureToomanyjoinsdetection_1437B/image_thumb_1.png" width="593" height="102" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p /&gt;  &lt;p&gt;Queries with too many joins might be a performance problem. Each join requires the database to perform additional work, and the complexity and cost of the query grows rapidly with each additional join. While relational database are optimized for handling joins, it is often more efficient to perform several separate queries instead of a single query with several joins in it.&lt;/p&gt;  &lt;p&gt;For OLTP systems, you should consider simplifying your queries or simplifying the data model. While I do not recommend avoiding joins completely, I strong discourage queries with large numbers of joins. Another issue to pay attention to is possible Cartesian products in queries contains joins, it is very easy to create such a thing and not notice it during development.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11325.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/24/profiler-new-feature-too-many-joins-detection.aspx</guid>
            <pubDate>Wed, 24 Feb 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11325.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/24/profiler-new-feature-too-many-joins-detection.aspx#feedback</comments>
            <slash:comments>15</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11325.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Profiler Speculative Feature: Query plans</title>
            <link>http://ayende.com/Blog/archive/2010/02/23/profiler-speculative-feature-query-plans.aspx</link>
            <description>&lt;p&gt;This isn’t a &lt;em&gt;new&lt;/em&gt; feature, because you can’t use it right now, but it is a &lt;em&gt;really&lt;/em&gt; nice feature that we are working on, and I couldn’t resist showing it off hot “off the press”, so to speak.&lt;/p&gt;  &lt;p&gt;Given the following query:&lt;/p&gt;  &lt;blockquote&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="#0000ff"&gt;SELECT&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;             &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id7_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;          &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;title7_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;subtitle&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;subtitle7_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;allowscomments&lt;/font&gt; &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;allowsco4_7_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;createdat&lt;/font&gt;      &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;createdat7_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;blogid&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;blogid3_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;           &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id3_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;           &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id0_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;        &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;title0_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#0000ff"&gt;TEXT&lt;/font&gt;         &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;text0_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;postedat&lt;/font&gt;     &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;postedat0_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;blogid&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;blogid0_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;userid&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;userid0_0_&lt;/font&gt;       &lt;br /&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt;   &lt;font color="#800000"&gt;blogs&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#0000ff"&gt;LEFT&lt;/font&gt; &lt;font color="#0000ff"&gt;OUTER&lt;/font&gt; &lt;font color="#0000ff"&gt;JOIN&lt;/font&gt; &lt;font color="#800000"&gt;posts&lt;/font&gt; &lt;font color="#800000"&gt;posts2_&lt;/font&gt;       &lt;br /&gt;         &lt;font color="#0000ff"&gt;ON&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt; &lt;font color="#c0c0c0"&gt;=&lt;/font&gt; &lt;font color="#800000"&gt;posts2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;blogid&lt;/font&gt;       &lt;br /&gt;&lt;font color="#0000ff"&gt;WHERE&lt;/font&gt;  &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt; &lt;font color="#c0c0c0"&gt;=&lt;/font&gt; &lt;font color="#000000"&gt;1&lt;/font&gt; &lt;font color="#008000"&gt;&lt;i&gt;/* @p0 */&lt;/i&gt;&lt;/font&gt;       &lt;br /&gt;      &lt;br /&gt;&lt;font color="#0000ff"&gt;SELECT&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;            &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;         &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;title0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#0000ff"&gt;TEXT&lt;/font&gt;          &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;text0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;postedat&lt;/font&gt;      &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;postedat0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;blogid&lt;/font&gt;        &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;blogid0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;userid&lt;/font&gt;        &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;userid0_1_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;postid&lt;/font&gt;   &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;postid3_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id3_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;id2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;name&lt;/font&gt;     &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;name2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;email&lt;/font&gt;    &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;email2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;homepage&lt;/font&gt; &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;homepage2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;ip&lt;/font&gt;       &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;ip2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#0000ff"&gt;TEXT&lt;/font&gt;     &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;text2_0_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;,&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;postid&lt;/font&gt;   &lt;font color="#0000ff"&gt;AS&lt;/font&gt; &lt;font color="#800000"&gt;postid2_0_&lt;/font&gt;       &lt;br /&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt;   &lt;font color="#800000"&gt;posts&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;       &lt;br /&gt;       &lt;font color="#0000ff"&gt;LEFT&lt;/font&gt; &lt;font color="#0000ff"&gt;OUTER&lt;/font&gt; &lt;font color="#0000ff"&gt;JOIN&lt;/font&gt; &lt;font color="#800000"&gt;comments&lt;/font&gt; &lt;font color="#800000"&gt;comments2_&lt;/font&gt;       &lt;br /&gt;         &lt;font color="#0000ff"&gt;ON&lt;/font&gt; &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;id&lt;/font&gt; &lt;font color="#c0c0c0"&gt;=&lt;/font&gt; &lt;font color="#800000"&gt;comments2_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;postid&lt;/font&gt;       &lt;br /&gt;&lt;font color="#0000ff"&gt;WHERE&lt;/font&gt;  &lt;font color="#800000"&gt;this_&lt;/font&gt;&lt;font color="#c0c0c0"&gt;.&lt;/font&gt;&lt;font color="#800000"&gt;blogid&lt;/font&gt; &lt;font color="#c0c0c0"&gt;=&lt;/font&gt; &lt;font color="#000000"&gt;1&lt;/font&gt; &lt;font color="#008000"&gt;&lt;i&gt;/* @p1 */&lt;/i&gt;&lt;/font&gt; &lt;/font&gt;&lt;/blockquote&gt;  &lt;p&gt;The profiler can show you the query plan using this UI: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerSpeculativeFeatureQueryplans_76A2/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerSpeculativeFeatureQueryplans_76A2/image_thumb.png" width="644" height="413" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And here is how the same query looks like using the query plan feature in Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerSpeculativeFeatureQueryplans_76A2/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerSpeculativeFeatureQueryplans_76A2/image_thumb_1.png" width="244" height="189" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So, why implement it?&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;This isn’t limited to SQL Server, the profiler can display query plans for: SQL Server, Oracle, PostgreSQL and MySQL&lt;/li&gt;    &lt;li&gt;This let you keep yourself in the flow, just hit a button to see the query plan, instead of copying the SQL, opening SSMS, displaying the query plan, etc.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Don’t discount the last one, making it easy is one of the core values of the profiler.&lt;/p&gt;  &lt;p&gt;The idea is that if you make it easy enough, the barriers for using it goes away. If you can instantly see the query plan for a query, you are far more likely to look at it than if it takes 30 seconds to get that. At that point, you would only do it when you already have a performance problem.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11327.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/23/profiler-speculative-feature-query-plans.aspx</guid>
            <pubDate>Tue, 23 Feb 2010 08:24:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11327.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/23/profiler-speculative-feature-query-plans.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11327.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Linq to SQL Profiler 1.0 Released!</title>
            <link>http://ayende.com/Blog/archive/2010/02/20/linq-to-sql-profiler-1.0-released.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_thumb.png" width="172" height="251" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Well, I planned to do it last week, but it got delay for personal reasons. &lt;/p&gt;  &lt;p&gt;But here it is, &lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt; is now out of beta, and I personally think it is awesome. Using the profiler, you gain valuable insight about the actual data access pattern of your application (which is usually abstracted away by the Linq to SQL framework). But the profiler goes beyond just dumping a heap of data on you, it takes it several steps further by:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Tying together queries and code, you can go directly from any query to the line of code that generated it, no more scratching about “what caused this query”.&lt;/li&gt;    &lt;li&gt;Analyzing your data access patterns and alerting your about bad practices and suggesting how to fix them.&lt;/li&gt;    &lt;li&gt;Provide detailed reports on your application’s database usage, perfect for sending to the DBA for optimization.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I got some really nice feedback from people with it:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_thumb_1.png" width="592" height="70" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/LinqtoSQLProfiler1.0Released_14950/image_thumb_2.png" width="597" height="64" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p /&gt;  &lt;p&gt;Happy linqing&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11326.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/20/linq-to-sql-profiler-1.0-released.aspx</guid>
            <pubDate>Sat, 20 Feb 2010 21:25:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11326.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/20/linq-to-sql-profiler-1.0-released.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11326.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Profiler new feature: Integrating with application frameworks</title>
            <link>http://ayende.com/Blog/archive/2010/02/14/profiler-new-feature-integrating-with-application-frameworks.aspx</link>
            <description>&lt;p&gt;One of the things that makes working with the &lt;a href="http://nhprof.com"&gt;profiler&lt;/a&gt; easier is the fact that it gives you not just information, but information in context. &lt;/p&gt;  &lt;p&gt;I was working with an app using Rhino Service Bus, and it really bothered me that I couldn’t immediately figure out what was the trigger for a session. When using ASP.Net or WCF, the &lt;a href="http://l2sprof.com"&gt;profiler&lt;/a&gt; can show the URL that triggered the request, but when we are not using a url based mechanism, that turns out to be much harder.&lt;/p&gt;  &lt;p&gt;So I set out to fix that, you can see the results below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureIntegratingwithapplica_1204E/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilernewfeatureIntegratingwithapplica_1204E/image_thumb_1.png" width="883" height="191" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p /&gt;  &lt;p&gt;This session was generated by a message batch containing messages for MyBooks, MyQueue, etc.&lt;/p&gt;  &lt;p&gt;The integration is composed of two parts, first, from the &lt;a href="http://efprof.com"&gt;profiler&lt;/a&gt; perspective, you now have the ProfilerIntegration.CurrentSessionContext property, which allows you to customize how the profiler detects the current context.&lt;/p&gt;  &lt;p&gt;The second part is the integration from the application framework itself, you can see how I did that for &lt;a href="http://github.com/ayende/rhino-esb/blob/master/Rhino.ServiceBus/Util/CurrentMessage.cs"&gt;Rhino Service Bus&lt;/a&gt;, which will dynamically detect the presence of the profiler and fill the appropriate values. The result makes it a lot easier to track down what is going on.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11315.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/14/profiler-new-feature-integrating-with-application-frameworks.aspx</guid>
            <pubDate>Sun, 14 Feb 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11315.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/14/profiler-new-feature-integrating-with-application-frameworks.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11315.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Reminder: Linq to SQL Profiler goes 1.0 on the 14th</title>
            <link>http://ayende.com/Blog/archive/2010/02/11/reminder-linq-to-sql-profiler-goes-1.0-on-the-14th.aspx</link>
            <description>&lt;p&gt;On the 14th of Febuary, &lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt; will complete its beta period.&lt;/p&gt;  &lt;p&gt;The 30% beta discount will be discontinued at that time, so if you think it is useful, you have better hurry up and show that you love it.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11318.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/11/reminder-linq-to-sql-profiler-goes-1.0-on-the-14th.aspx</guid>
            <pubDate>Wed, 10 Feb 2010 22:21:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11318.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/11/reminder-linq-to-sql-profiler-goes-1.0-on-the-14th.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11318.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Say hello to Uber Prof</title>
            <link>http://ayende.com/Blog/archive/2010/02/08/say-hello-to-uber-prof.aspx</link>
            <description>&lt;p&gt;I got several requests for this, so I am making &lt;a href="http://hibernatingrhinos.com/products/UberProf"&gt;Uber Prof&lt;/a&gt; itself available for purchasing.&lt;/p&gt;  &lt;p&gt;What is Uber Prof? &lt;/p&gt;  &lt;p&gt;It is a short hand way of saying: All the OR/M profilers that we make.&lt;/p&gt;  &lt;p&gt;An Uber Prof license gives you the ability to use:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://nhprof.com/"&gt;NHibernate Profiler&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://hibernateprofiler.com/"&gt;Hibernate Profiler&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://efprof.com"&gt;Entity Framework Profiler&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And it will automatically give you the ability to use any additional profilers that we will create. And yes, there is an upgrade path if you already purchased a single profiler license and would like to upgrade to Uber Prof.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11307.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/08/say-hello-to-uber-prof.aspx</guid>
            <pubDate>Mon, 08 Feb 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11307.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/08/say-hello-to-uber-prof.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11307.aspx</wfw:commentRss>
        </item>
        <item>
            <title>What happens behind the scenes: NHibernate, Linq to SQL, Entity Framework scenario analysis</title>
            <link>http://ayende.com/Blog/archive/2010/02/04/what-happens-behind-the-scenes-nhibernate-linq-to-sql-entity.aspx</link>
            <description>&lt;p&gt;One of the things that I began doing since starting to work on &lt;a href="http://nhprof.com"&gt;multiple&lt;/a&gt; &lt;a href="http://l2sprof.com"&gt;OR/M&lt;/a&gt; &lt;a href="http://efprof.com"&gt;Profilers&lt;/a&gt; is to compare how all of them are handling a particular task. This is by no means a comparative analysis, but it is an interesting data point.&lt;/p&gt;  &lt;p&gt;The scenario in question is loading a blog with all its posts and comments.&lt;/p&gt;  &lt;p&gt;Let us start with NHibernate:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;var blogs = s.CreateQuery(
    &lt;span class="str"&gt;@"from Blog b 
        left join fetch b.Posts p 
        left join fetch p.Comments 
    where b.Id = :id"&lt;/span&gt;)
    .SetParameter(&lt;span class="str"&gt;"id"&lt;/span&gt;, 1)
    .List&amp;lt;Blog&amp;gt;();&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;Will generate the following SQL  &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;select&lt;/span&gt; blog0_.Id             &lt;span class="kwrd"&gt;as&lt;/span&gt; Id7_0_,
       posts1_.Id            &lt;span class="kwrd"&gt;as&lt;/span&gt; Id0_1_,
       comments2_.Id         &lt;span class="kwrd"&gt;as&lt;/span&gt; Id2_2_,
       blog0_.Title          &lt;span class="kwrd"&gt;as&lt;/span&gt; Title7_0_,
       blog0_.Subtitle       &lt;span class="kwrd"&gt;as&lt;/span&gt; Subtitle7_0_,
       blog0_.AllowsComments &lt;span class="kwrd"&gt;as&lt;/span&gt; AllowsCo4_7_0_,
       blog0_.CreatedAt      &lt;span class="kwrd"&gt;as&lt;/span&gt; CreatedAt7_0_,
       posts1_.Title         &lt;span class="kwrd"&gt;as&lt;/span&gt; Title0_1_,
       posts1_.Text          &lt;span class="kwrd"&gt;as&lt;/span&gt; Text0_1_,
       posts1_.PostedAt      &lt;span class="kwrd"&gt;as&lt;/span&gt; PostedAt0_1_,
       posts1_.BlogId        &lt;span class="kwrd"&gt;as&lt;/span&gt; BlogId0_1_,
       posts1_.UserId        &lt;span class="kwrd"&gt;as&lt;/span&gt; UserId0_1_,
       posts1_.BlogId        &lt;span class="kwrd"&gt;as&lt;/span&gt; BlogId0__,
       posts1_.Id            &lt;span class="kwrd"&gt;as&lt;/span&gt; Id0__,
       comments2_.Name       &lt;span class="kwrd"&gt;as&lt;/span&gt; Name2_2_,
       comments2_.Email      &lt;span class="kwrd"&gt;as&lt;/span&gt; Email2_2_,
       comments2_.HomePage   &lt;span class="kwrd"&gt;as&lt;/span&gt; HomePage2_2_,
       comments2_.Ip         &lt;span class="kwrd"&gt;as&lt;/span&gt; Ip2_2_,
       comments2_.Text       &lt;span class="kwrd"&gt;as&lt;/span&gt; Text2_2_,
       comments2_.PostId     &lt;span class="kwrd"&gt;as&lt;/span&gt; PostId2_2_,
       comments2_.PostId     &lt;span class="kwrd"&gt;as&lt;/span&gt; PostId1__,
       comments2_.Id         &lt;span class="kwrd"&gt;as&lt;/span&gt; Id1__
&lt;span class="kwrd"&gt;from&lt;/span&gt;   Blogs blog0_
       &lt;span class="kwrd"&gt;left&lt;/span&gt; &lt;span class="kwrd"&gt;outer&lt;/span&gt; &lt;span class="kwrd"&gt;join&lt;/span&gt; Posts posts1_
         &lt;span class="kwrd"&gt;on&lt;/span&gt; blog0_.Id = posts1_.BlogId
       &lt;span class="kwrd"&gt;left&lt;/span&gt; &lt;span class="kwrd"&gt;outer&lt;/span&gt; &lt;span class="kwrd"&gt;join&lt;/span&gt; Comments comments2_
         &lt;span class="kwrd"&gt;on&lt;/span&gt; posts1_.Id = comments2_.PostId
&lt;span class="kwrd"&gt;where&lt;/span&gt;  blog0_.Id = 1 /* @p0 */&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;This result in a fairly simple query plan:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_thumb.png" width="795" height="262" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;However, you should note that this also result in a Cartesian product, which may not be what you wanted.&lt;/p&gt;

&lt;p&gt;Linq to SQL doesn’t really provide a good way to express what I wanted, but it does get the job done:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;var dataLoadOptions = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataLoadOptions();
dataLoadOptions.LoadWith&amp;lt;Blog&amp;gt;(x =&amp;gt; x.Posts);
dataLoadOptions.LoadWith&amp;lt;Post&amp;gt;(x =&amp;gt; x.Comments);
&lt;span class="kwrd"&gt;using&lt;/span&gt; (var db = &lt;span class="kwrd"&gt;new&lt;/span&gt; BlogModelDataContext(conStr)
{
    LoadOptions =  dataLoadOptions
})
{
    db.Blogs.Where(x =&amp;gt; x.Id == 1).ToList();
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;Interestingly enough, this does not generate a single query, but two queries:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- statement #1&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [t0].[Id],
       [t0].[Title],
       [t0].[Subtitle],
       [t0].[AllowsComments],
       [t0].[CreatedAt]
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   [dbo].[Blogs] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [t0]
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  [t0].[Id] = 1 /* @p0 */

&lt;span class="rem"&gt;-- statement #2&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;   [t0].[Id],
         [t0].[Title],
         [t0].[Text],
         [t0].[PostedAt],
         [t0].[BlogId],
         [t0].[UserId],
         [t1].[Id]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id2],
         [t1].[Name],
         [t1].[Email],
         [t1].[HomePage],
         [t1].[Ip],
         [t1].[Text]     &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text2],
         [t1].[PostId],
         (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(* )
          &lt;span class="kwrd"&gt;FROM&lt;/span&gt;   [dbo].[Comments] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [t2]
          &lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  [t2].[PostId] = [t0].[Id]) &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;value&lt;/span&gt;]
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;     [dbo].[Posts] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [t0]
         &lt;span class="kwrd"&gt;LEFT&lt;/span&gt; &lt;span class="kwrd"&gt;OUTER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; [dbo].[Comments] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [t1]
           &lt;span class="kwrd"&gt;ON&lt;/span&gt; [t1].[PostId] = [t0].[Id]
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;    [t0].[BlogId] = 1 /* @x1 */
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; [t0].[Id],
         [t1].[Id]&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;The interesting bit is that while there are two queries here, this method does &lt;em&gt;not&lt;/em&gt; generate a Cartesian product, so I have to consider this a plus. What I would like to know is whatever this is intentionally so or just a result of the way Linq to SQL eager loading is structured. &lt;/p&gt;

&lt;p&gt;The query plan for this is simple as well:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_thumb_1.png" width="1302" height="390" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Finally, Entity Framework &lt;b&gt;(both 3.5 and 4.0)&lt;/b&gt;, using this code: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;db.Blogs
    .Include(&lt;span class="str"&gt;"Posts"&lt;/span&gt;)
    .Include(&lt;span class="str"&gt;"Posts.Comments"&lt;/span&gt;)
    .Where(x =&amp;gt; x.Id == 1)
    .ToList();&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;This code will generate: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;   [Project2].[Id]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id],
         [Project2].[Title]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Title],
         [Project2].[Subtitle]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Subtitle],
         [Project2].[AllowsComments] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [AllowsComments],
         [Project2].[CreatedAt]      &lt;span class="kwrd"&gt;AS&lt;/span&gt; [CreatedAt],
         [Project2].[C1]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C1],
         [Project2].[C4]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C2],
         [Project2].[Id1]            &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id1],
         [Project2].[Title1]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Title1],
         [Project2].[Text]           &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text],
         [Project2].[PostedAt]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostedAt],
         [Project2].[BlogId]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [BlogId],
         [Project2].[UserId]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [UserId],
         [Project2].[C3]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C3],
         [Project2].[C2]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C4],
         [Project2].[Id2]            &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id2],
         [Project2].[Name]           &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Name],
         [Project2].[Email]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Email],
         [Project2].[HomePage]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [HomePage],
         [Project2].[Ip]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Ip],
         [Project2].[Text1]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text1],
         [Project2].[PostId]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostId]
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;     (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [Extent1].[Id]             &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id],
                 [Extent1].[Title]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Title],
                 [Extent1].[Subtitle]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Subtitle],
                 [Extent1].[AllowsComments] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [AllowsComments],
                 [Extent1].[CreatedAt]      &lt;span class="kwrd"&gt;AS&lt;/span&gt; [CreatedAt],
                 1                          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C1],
                 [Project1].[Id]            &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id1],
                 [Project1].[Title]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Title1],
                 [Project1].[Text]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text],
                 [Project1].[PostedAt]      &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostedAt],
                 [Project1].[BlogId]        &lt;span class="kwrd"&gt;AS&lt;/span&gt; [BlogId],
                 [Project1].[UserId]        &lt;span class="kwrd"&gt;AS&lt;/span&gt; [UserId],
                 [Project1].[Id1]           &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id2],
                 [Project1].[Name]          &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Name],
                 [Project1].[Email]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Email],
                 [Project1].[HomePage]      &lt;span class="kwrd"&gt;AS&lt;/span&gt; [HomePage],
                 [Project1].[Ip]            &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Ip],
                 [Project1].[Text1]         &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text1],
                 [Project1].[PostId]        &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostId],
                 &lt;span class="kwrd"&gt;CASE&lt;/span&gt; 
                   &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ([Project1].[C1] &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;) &lt;span class="kwrd"&gt;THEN&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(&lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;)
                   &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; &lt;span class="kwrd"&gt;CASE&lt;/span&gt; 
                          &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ([Project1].[Id1] &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;) &lt;span class="kwrd"&gt;THEN&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(&lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;)
                          &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 1
                        &lt;span class="kwrd"&gt;END&lt;/span&gt;
                 &lt;span class="kwrd"&gt;END&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C2],
                 &lt;span class="kwrd"&gt;CASE&lt;/span&gt; 
                   &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ([Project1].[C1] &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;) &lt;span class="kwrd"&gt;THEN&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(&lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;)
                   &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; &lt;span class="kwrd"&gt;CASE&lt;/span&gt; 
                          &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ([Project1].[Id1] &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;) &lt;span class="kwrd"&gt;THEN&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(&lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;)
                          &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 1
                        &lt;span class="kwrd"&gt;END&lt;/span&gt;
                 &lt;span class="kwrd"&gt;END&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C3],
                 [Project1].[C1]            &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C4]
          &lt;span class="kwrd"&gt;FROM&lt;/span&gt;   [dbo].[Blogs] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Extent1]
                 &lt;span class="kwrd"&gt;LEFT&lt;/span&gt; &lt;span class="kwrd"&gt;OUTER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [Extent2].[Id]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id],
                                         [Extent2].[Title]    &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Title],
                                         [Extent2].[Text]     &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text],
                                         [Extent2].[PostedAt] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostedAt],
                                         [Extent2].[BlogId]   &lt;span class="kwrd"&gt;AS&lt;/span&gt; [BlogId],
                                         [Extent2].[UserId]   &lt;span class="kwrd"&gt;AS&lt;/span&gt; [UserId],
                                         [Extent3].[Id]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Id1],
                                         [Extent3].[Name]     &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Name],
                                         [Extent3].[Email]    &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Email],
                                         [Extent3].[HomePage] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [HomePage],
                                         [Extent3].[Ip]       &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Ip],
                                         [Extent3].[Text]     &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Text1],
                                         [Extent3].[PostId]   &lt;span class="kwrd"&gt;AS&lt;/span&gt; [PostId],
                                         1                    &lt;span class="kwrd"&gt;AS&lt;/span&gt; [C1]
                                  &lt;span class="kwrd"&gt;FROM&lt;/span&gt;   [dbo].[Posts] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Extent2]
                                         &lt;span class="kwrd"&gt;LEFT&lt;/span&gt; &lt;span class="kwrd"&gt;OUTER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; [dbo].[Comments] &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Extent3]
                                           &lt;span class="kwrd"&gt;ON&lt;/span&gt; [Extent2].[Id] = [Extent3].[PostId]) &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Project1]
                   &lt;span class="kwrd"&gt;ON&lt;/span&gt; [Extent1].[Id] = [Project1].[BlogId]
          &lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  1 = [Extent1].[Id]) &lt;span class="kwrd"&gt;AS&lt;/span&gt; [Project2]
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; [Project2].[Id] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;,
         [Project2].[C4] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;,
         [Project2].[Id1] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;,
         [Project2].[C3] ASC&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;The query plan for this seems overly complicated:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/WhathappensbehindthescenesNHibernateLinq_1991/image_thumb_2.png" width="1459" height="258" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;If you’ll look closely, you’ll see that it generate a join between Blogs, Posts and Comments, essentially creating a Cartesian product between all three. &lt;/p&gt;

&lt;p&gt;I am not going to offer commentary on the results, but open a discussion on them. &lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11303.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/02/04/what-happens-behind-the-scenes-nhibernate-linq-to-sql-entity.aspx</guid>
            <pubDate>Thu, 04 Feb 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11303.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/02/04/what-happens-behind-the-scenes-nhibernate-linq-to-sql-entity.aspx#feedback</comments>
            <slash:comments>27</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11303.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Linq to SQL Profiler release is upcoming</title>
            <link>http://ayende.com/Blog/archive/2010/01/31/linq-to-sql-profiler-release-is-upcoming.aspx</link>
            <description>&lt;p&gt;Following the tradition of choosing meaningful calendar dates (although the first few cases were accidentals) for my releases, the &lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt; will be released in a 1.0 version on the 14th February.&lt;/p&gt;  &lt;p&gt;At that time, the &lt;em&gt;beta discount will be discontinued&lt;/em&gt;, so hurry up and show Linq to SQL that you love it by buying the profiler.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11299.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/01/31/linq-to-sql-profiler-release-is-upcoming.aspx</guid>
            <pubDate>Sun, 31 Jan 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11299.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/01/31/linq-to-sql-profiler-release-is-upcoming.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11299.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Linq to SQL Profiler Video</title>
            <link>http://ayende.com/Blog/archive/2010/01/30/linq-to-sql-profiler-video.aspx</link>
            <description>&lt;p&gt;The guys from &lt;a href="http://www.codesmithtools.com/"&gt;CodeSmith&lt;/a&gt; has just put out a sample video showing how to use &lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;object width="500" height="315"&gt;&lt;param name="movie" value="http://www.youtube.com/v/c_taW3C4o4M&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;border=1" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed src="http://www.youtube.com/v/c_taW3C4o4M&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="315" /&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;I &lt;em&gt;love&lt;/em&gt; it!&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11298.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/01/30/linq-to-sql-profiler-video.aspx</guid>
            <pubDate>Sat, 30 Jan 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11298.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/01/30/linq-to-sql-profiler-video.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11298.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Profiler New Feature: Side by Side diff</title>
            <link>http://ayende.com/Blog/archive/2010/01/26/profiler-new-feature-side-by-side-diff.aspx</link>
            <description>&lt;p&gt;The &lt;a href="http://nhprof.com"&gt;profiler&lt;/a&gt; &lt;a href="http://efprof.com"&gt;could&lt;/a&gt; &lt;a href="http://l2sprof.com"&gt;do&lt;/a&gt; &lt;a href="http://hibernateprofiler.com"&gt;session&lt;/a&gt; diffs (showing the difference between executed statements between two sessions) for a while now, but we got some requests for changing it to follow a more traditional source control diff style.&lt;/p&gt;  &lt;p&gt;This is now done, and it should make it easier to understand the changes between two sessions:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerNewFeatureSidebySidediff_961B/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ProfilerNewFeatureSidebySidediff_961B/image_thumb.png" width="700" height="550" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11294.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/01/26/profiler-new-feature-side-by-side-diff.aspx</guid>
            <pubDate>Tue, 26 Jan 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11294.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/01/26/profiler-new-feature-side-by-side-diff.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11294.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>