<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>NH Prof</title>
        <link>http://ayende.com/Blog/category/551.aspx</link>
        <description>NH Prof</description>
        <language>en-US</language>
        <copyright>Ayende Rahien</copyright>
        <managingEditor>Ayende@ayende.com</managingEditor>
        <generator>Subtext Version 2.0.0.0</generator>
        <item>
            <title>Sometimes you really need a profiler handy</title>
            <link>http://ayende.com/Blog/archive/2010/03/11/sometimes-you-really-need-a-profiler-handy.aspx</link>
            <description>&lt;p&gt;As part of the performance work I am doing for &lt;a href="http://nhprof.com"&gt;Uber&lt;/a&gt; &lt;a href="http://efprof.com"&gt;Prof&lt;/a&gt;, I fixed a couple of issues related to profiling &lt;em&gt;very&lt;/em&gt; busy applications.&lt;/p&gt;  &lt;p&gt;Here is the result on processing a 4GB input file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/Sometimesyoureallyneedaprofilerhandy_11D08/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/Sometimesyoureallyneedaprofilerhandy_11D08/image_thumb.png" width="964" height="335" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I can’t say that the profiler is &lt;em&gt;happy &lt;/em&gt;about it, but it works. &lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11344.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/03/11/sometimes-you-really-need-a-profiler-handy.aspx</guid>
            <pubDate>Thu, 11 Mar 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11344.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/03/11/sometimes-you-really-need-a-profiler-handy.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11344.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Lessons learned from building the NHibernate Profiler</title>
            <link>http://ayende.com/Blog/archive/2010/03/08/lessons-learned-from-building-the-nhibernate-profiler.aspx</link>
            <description>&lt;p&gt;Last week I gave a talk about the things I learned from building NH Prof.&lt;/p&gt;  &lt;p&gt;Skills Matter had recorded the session and made it &lt;a href="http://skillsmatter.com/podcast/open-source-dot-net/lessons-learned-from-building-the-nhibernate-profiler"&gt;available&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Looking forward for your comments, but I should disclaimer that this was after a full day of teaching and on 50 min of sleep in the last 48 hours&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11341.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/03/08/lessons-learned-from-building-the-nhibernate-profiler.aspx</guid>
            <pubDate>Mon, 08 Mar 2010 10:00:00 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/11341.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2010/03/08/lessons-learned-from-building-the-nhibernate-profiler.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11341.aspx</wfw:commentRss>
        </item>
        <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>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>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>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>
        <item>
            <title>UberProf new feature: Query Plan Cache Misuse</title>
            <link>http://ayende.com/Blog/archive/2010/01/13/uberprof-new-feature-query-plan-cache-misuse.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/UberProfnewfeatureQueryPlanCacheMisuse_AD23/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/UberProfnewfeatureQueryPlanCacheMisuse_AD23/image_thumb.png" width="627" height="207" /&gt;&lt;/a&gt; This is a new feature available for &lt;a href="http://nhprof.com"&gt;NHibernate Profiler&lt;/a&gt;*, &lt;a href="http://l2sprof.com"&gt;Linq to SQL Profiler&lt;/a&gt; and &lt;a href="http://efprof.com"&gt;Entity Profiler&lt;/a&gt;. Basically, it detects when the same query is executed with different parameter sizes, which generate different query plan in the query cache.&lt;/p&gt;  &lt;p&gt;Let us say that we issue two queries, to find users by name. (Note that I am using a syntax that will show you the size of the parameters, to demonstrate the problem).&lt;/p&gt;  &lt;p&gt;We can do this using the following queries.&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;exec sp_executesql 
      N'SELECT * FROM Users WHERE Username = @username',
      N'@username nvarchar(3)',
      @username=N'bob'
exec sp_executesql 
      N'SELECT * FROM Users WHERE Username = @username',
      N'@username nvarchar(4)',
      @username=N'john'&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;This sort of code result in &lt;em&gt;two&lt;/em&gt; query plans stored in the database query cache, because of the different parameter sizes. In fact, if we assume that the Username column has a length of 16, this single query may take up 16 places in the query cache.&lt;/p&gt;

&lt;p&gt;Worse, if you have two parameters whose size change, such as username (length 16) and password (length 16), you may take up to 256 places in the query cache. Obviously, if you use more parameters, or if their length is higher, the number of places that a single query can take in the query cache goes up rapidly.&lt;/p&gt;

&lt;p&gt;This can cause performance problems as the database need to keep track of more query plans (uses more memory) may need evict query plans from the cache, which would result in having to rebuild the query plan (increase server load and query time).&lt;/p&gt;

&lt;p /&gt;

&lt;p&gt;* Please note that detecting this in NHibernate requires the trunk version of NHibernate. And it is pretty useless there, since on the trunk, NHibernate will never generate this issue.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11278.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2010/01/13/uberprof-new-feature-query-plan-cache-misuse.aspx</guid>
            <pubDate>Wed, 13 Jan 2010 10:00:00 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2010/01/13/uberprof-new-feature-query-plan-cache-misuse.aspx#feedback</comments>
            <slash:comments>21</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11278.aspx</wfw:commentRss>
        </item>
        <item>
            <title>&amp;Uuml;berProf new feature: Fully keyboard enabled</title>
            <link>http://ayende.com/Blog/archive/2009/12/17/uumlberprof-new-feature-fully-keyboard-enabled.aspx</link>
            <description>&lt;p&gt;For a long time, most of the work in the profiler (&lt;a href="http://nhprof.com"&gt;NH Prof&lt;/a&gt;, &lt;a href="http://hibernateprofiler.com"&gt;HProf&lt;/a&gt;, &lt;a href="http://l2sprof.com"&gt;L2S Prof&lt;/a&gt; &amp;amp; &lt;a href="http://efprof.com"&gt;EF Prof&lt;/a&gt;) could be done only with the use of the mouse. That annoyed a bunch of people, but it didn’t really bother me.  &lt;a href="http://devlicious.com/blogs/rob_eisenberg/"&gt;Rob&lt;/a&gt; fixed this recently, and I cannot &lt;em&gt;believe&lt;/em&gt; what kind of a difference it makes.&lt;/p&gt;  &lt;p&gt;Here are the shortcuts:&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="531"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;S&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Focus on Sessions tab header&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;T&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Focus on Statements tab header&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;D&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Focus on Details tab header&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;F&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Focus on Statistics tab header&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Left / Right&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Move to the next / prev tab&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Down / Up&lt;/td&gt;        &lt;td valign="top" width="329"&gt;Move to next session / statement&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Using those, you can use the common functionality of the profiler without touching the mouse.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/11242.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2009/12/17/uumlberprof-new-feature-fully-keyboard-enabled.aspx</guid>
            <pubDate>Thu, 17 Dec 2009 10:00:00 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2009/12/17/uumlberprof-new-feature-fully-keyboard-enabled.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/11242.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>