﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Thanks, I updated the documentations
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment21</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment21</guid><pubDate>Thu, 21 Jan 2010 15:02:33 GMT</pubDate></item><item><title>gunteman commented on UberProf new feature: Query Plan Cache Misuse</title><description>Yeah, I know. It just sounded a bit wrong to me. High cache usage is something good, in my book.
  
  
Maybe "higher " can be substituted for "inefficient", to remove any doubts
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment20</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment20</guid><pubDate>Fri, 15 Jan 2010 09:54:43 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Gunteman,
  
It is an issue of semantics, since we have more cache entries, for what is basically the same query.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment19</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment19</guid><pubDate>Fri, 15 Jan 2010 05:29:20 GMT</pubDate></item><item><title>gunteman commented on UberProf new feature: Query Plan Cache Misuse</title><description>I think the wording is a bit confusing..
  
  
"Different parameter sizes result in higher query plan cache usage".
  
  
If anything, the cache usage is reduced. The cache size increases, though.
  
  
Maybe "Different parameter sizes result in reduced use of cached query plans"?
  
  
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment18</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment18</guid><pubDate>Thu, 14 Jan 2010 22:00:49 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>tobi,
  
NHibernate already does that when you put the constant as part of the query, yes.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment17</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment17</guid><pubDate>Thu, 14 Jan 2010 03:31:17 GMT</pubDate></item><item><title>tobi commented on UberProf new feature: Query Plan Cache Misuse</title><description>I wonder if you can make NHibernate not parameterize the value of constant parameters. This should be a performance improvement as the optimizer has more information. It also does not pollute the cache to much because at most as many slots are filled than you have distinct queries in your code.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment16</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment16</guid><pubDate>Wed, 13 Jan 2010 22:12:32 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Dmitry,
  
Why wouldn't it be cached?
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment15</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment15</guid><pubDate>Wed, 13 Jan 2010 16:39:37 GMT</pubDate></item><item><title>Dmitry commented on UberProf new feature: Query Plan Cache Misuse</title><description>Oren,
  
  
Does your profiler actually checks execution plans? I doubt a query like
  
  
INSERT INTO (field1, ... , @fieldN) VALUES (@value1, ... , @valueN) 
  
  
would have the execution plan cached.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment14</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment14</guid><pubDate>Wed, 13 Jan 2010 16:38:47 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Jarod,
  
That is just an example, to show the problem, not talking about those specific queries
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment13</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment13</guid><pubDate>Wed, 13 Jan 2010 16:38:05 GMT</pubDate></item><item><title>Jarod commented on UberProf new feature: Query Plan Cache Misuse</title><description>Ya, not for inserts.
  
  
I was referring to this part of the post: 
  
  
=========================
  
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).
  
  
We can do this using the following queries.
  
  
    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'
  
  
This sort of code result in two query plans stored in the database query cache, because of the different parameter sizes. 
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment12</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment12</guid><pubDate>Wed, 13 Jan 2010 16:12:24 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Jarod,
  
Note that I am doing INSERTs here, not queries, I don't think that you can compile that.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment11</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment11</guid><pubDate>Wed, 13 Jan 2010 16:06:51 GMT</pubDate></item><item><title>Jarod commented on UberProf new feature: Query Plan Cache Misuse</title><description>In EF, isnt this solved by compiling the query?
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment10</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment10</guid><pubDate>Wed, 13 Jan 2010 16:04:53 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Dmitry,
  
This result in the same alert as well:
  
using (var db = new Entities(conStr))
  
{
  
    for (int i = 0; i &lt; 5; i++)
  
    {
  
        db.AddToUsers(new Users
  
        {
  
            Username = new string('a', i)
  
        });
  
    }
  
    db.SaveChanges();
  
}
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment9</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment9</guid><pubDate>Wed, 13 Jan 2010 15:48:04 GMT</pubDate></item><item><title>Dmitry commented on UberProf new feature: Query Plan Cache Misuse</title><description>I did not realize it has this issue with binary data. I was talking about strings/decimals.
  
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment8</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment8</guid><pubDate>Wed, 13 Jan 2010 15:44:54 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Dmitry,
  
In other words, EF certainly have this issue.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment7</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment7</guid><pubDate>Wed, 13 Jan 2010 15:31:07 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Dmitry,
  
The following EF 3.5 code is going to result in this alert:
  
  
 using (var db = new Entities(conStr))
  
 {
  
     for (int i = 0; i &lt; 5; i++)
  
     {
  
         db.AddToUsers(new Users
  
                           {
  
                               Password = new byte[i] 
  
                           });
  
     }
  
     db.SaveChanges();
  
 }
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment6</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment6</guid><pubDate>Wed, 13 Jan 2010 15:30:19 GMT</pubDate></item><item><title>Dmitry commented on UberProf new feature: Query Plan Cache Misuse</title><description>@Frans,
  
  
EF never had that bug.
  
  
It has a different issue though. Constant query parameters are not parameterized. This is true in EF4 as well. Does anyone know if it can cause the same execution plan problem?
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment5</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment5</guid><pubDate>Wed, 13 Jan 2010 15:27:53 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf new feature: Query Plan Cache Misuse</title><description>Rumburak,
  
You set the parameter length (which is separate than the _value_ length.
  
  
Frans,
  
Yes, it is refering to this bug.
  
  
Dmitry,
  
Yes.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment4</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment4</guid><pubDate>Wed, 13 Jan 2010 14:18:21 GMT</pubDate></item><item><title>Dmitry commented on UberProf new feature: Query Plan Cache Misuse</title><description>I guess NH has finally been modified to set parameter length even when prepare_sql is false. I modified the source locally to do that a while ago.
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment3</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment3</guid><pubDate>Wed, 13 Jan 2010 14:13:52 GMT</pubDate></item><item><title>Frans Bouma commented on UberProf new feature: Query Plan Cache Misuse</title><description>Isn't this due to a bug in EF and L2S which are solved in 4.0 and L2S for .net 4?
  
  
Any sane o/r mapper would simply pass the length of the field to filter in the parameter (IMHO)
  
  
(btw, the font in this textbox is really small in FF3.5)
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment2</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment2</guid><pubDate>Wed, 13 Jan 2010 11:31:31 GMT</pubDate></item><item><title>rumburak commented on UberProf new feature: Query Plan Cache Misuse</title><description>Ok, so how to avoid variable length with varchars? Pad them with spaces or what?
  
</description><link>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment1</link><guid>http://ayende.com/4363/uberprof-new-feature-query-plan-cache-misuse#comment1</guid><pubDate>Wed, 13 Jan 2010 11:27:29 GMT</pubDate></item></channel></rss>