﻿<?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>Pawel Lesnikowski commented on Find the differences: The optimization that changed behavior</title><description>As far as I remember IN query has limits at least in Oracle database.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment17</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment17</guid><pubDate>Mon, 21 Sep 2009 06:20:50 GMT</pubDate></item><item><title>gunteman commented on Find the differences: The optimization that changed behavior</title><description>It's important to at least have the option to use the IN query version, especially if the query should be decorated from other sources, such as Rhino.Security
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment16</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment16</guid><pubDate>Sun, 20 Sep 2009 12:48:02 GMT</pubDate></item><item><title>Paul Hatcher commented on Find the differences: The optimization that changed behavior</title><description>Is this still true, I applied a patch (see 
[http://nhjira.koah.net/browse/NHSR-17](http://nhjira.koah.net/browse/NHSR-17)) that addressed at least one use case of this.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment15</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment15</guid><pubDate>Thu, 17 Sep 2009 11:09:42 GMT</pubDate></item><item><title>Chris Smith commented on Find the differences: The optimization that changed behavior</title><description>I can see a big stinking NullReferenceException about to happen though :)
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment14</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment14</guid><pubDate>Thu, 17 Sep 2009 10:54:04 GMT</pubDate></item><item><title>Johannes Gustafsson commented on Find the differences: The optimization that changed behavior</title><description>I Guess one solution could be some kind of this?
  
  
public IList
&lt;t Search
&lt;t(string query)
  
{
  
    return session
  
        .CreateCriteria
&lt;t()
  
        .Add(Restrictions.In("id", DoLuceneSearch(query).Where(x =&gt; typeof(T).IsAssignableFrom(Assembly.GetExecutingAssembly().GetType(x.className))).Select(x=&gt;x.Id)))
  
        .List();
  
}
  
&gt;</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment13</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment13</guid><pubDate>Thu, 17 Sep 2009 06:51:17 GMT</pubDate></item><item><title>Howard Pinsley commented on Find the differences: The optimization that changed behavior</title><description>Expanding on what Johannes mentioned, it seems like you can actually get an non-matching item of type T that exits with an id that was returned by the Lucene search for an entirely different class?
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment12</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment12</guid><pubDate>Wed, 16 Sep 2009 15:34:39 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the differences: The optimization that changed behavior</title><description>Dmitriy,
  
1 isn't true, the DoLuceneQuery doesn't hit the DB.
  
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment11</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment11</guid><pubDate>Wed, 16 Sep 2009 09:11:54 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the differences: The optimization that changed behavior</title><description>Mogens,
  
Yep :-)
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment10</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment10</guid><pubDate>Wed, 16 Sep 2009 09:03:00 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the differences: The optimization that changed behavior</title><description>Johannes,
  
Yep, that is a big change in behavior.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment9</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment9</guid><pubDate>Wed, 16 Sep 2009 09:02:22 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the differences: The optimization that changed behavior</title><description>Configurator,
  
Sort order is one such problem, yes.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment8</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment8</guid><pubDate>Wed, 16 Sep 2009 09:00:29 GMT</pubDate></item><item><title>Mogens Heller Grabe commented on Find the differences: The optimization that changed behavior</title><description>One difference is that the first version will take advantage of the 1st level cache and the 2nd level entity cache if it is enabled.
  
  
The second version will always go to the database.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment7</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment7</guid><pubDate>Wed, 16 Sep 2009 06:04:06 GMT</pubDate></item><item><title>Johannes Gustafsson commented on Find the differences: The optimization that changed behavior</title><description>The first query uses idAndClass.className to get the entity. If it is possible for idAndClass.className to be something else than T, then the second query could return an entirely different entity.
  
  
On the other hand, the first query would throw in this case.
  
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment6</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment6</guid><pubDate>Wed, 16 Sep 2009 06:01:00 GMT</pubDate></item><item><title>Bunter commented on Find the differences: The optimization that changed behavior</title><description>Will the second one fail if no rows are returned by lucenesearch?
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment5</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment5</guid><pubDate>Wed, 16 Sep 2009 05:48:02 GMT</pubDate></item><item><title>Markus Zywitza commented on Find the differences: The optimization that changed behavior</title><description>1) Original code loads proxies, the optimized code loads the full objects. 
  
  
2) The optimized code loads only T while the original code loads T and subclasses of T
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment4</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment4</guid><pubDate>Wed, 16 Sep 2009 05:29:31 GMT</pubDate></item><item><title>Dmitry commented on Find the differences: The optimization that changed behavior</title><description>The query in the second example would always hit the database but it would only be done once. You might hit a 2100 parameter limit if it uses the IN clause.
  
  
The first example can take advantage of the identity map.
  
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment3</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment3</guid><pubDate>Wed, 16 Sep 2009 05:00:01 GMT</pubDate></item><item><title>Dmitriy Nagirnyak commented on Find the differences: The optimization that changed behavior</title><description>I think 3 major differences are:
  
1. The 2nd case executes (in theory) 2 SQL queries. One to return Class+Id, the 2nd to return the actual list (probably using SELECT... FROM... WHERE id in (...). With all the pros/cons.
  
2. The 2nd case ignores the NH 2nd level cache.
  
3. The 2nd approach ignores the class thus you cannot use search with inheritance.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment2</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment2</guid><pubDate>Wed, 16 Sep 2009 04:49:25 GMT</pubDate></item><item><title>configurator commented on Find the differences: The optimization that changed behavior</title><description>Is it possible that DoLuceneSearch can return the same row multiple times?
  
Also, this would do this in a different sort order if I'm not mistaken. (That is, if sort order in even an issue at that level which I assume it is)
  
  
Note: I don't use NHibernate, and I have no idea what Lucene is, so this is nothing more than an educated guess.
</description><link>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment1</link><guid>http://ayende.com/4198/find-the-differences-the-optimization-that-changed-behavior#comment1</guid><pubDate>Wed, 16 Sep 2009 04:34:03 GMT</pubDate></item></channel></rss>