I have a simple hql query which looks something like:
"from myObject obj where obj.prop = :paramValue"
This should return 1,000 - 10,000 objects.
Unfortunately this one simple hql query generates ~ 20,000 server calls (this can be seen by enabling 'show_sql' and then using db server profiler - which shows a huge number of db rpc calls (Sql server 2008). Each generates sql statement is fairly complicated.
It *appears* that NHibernate is looping through all the possible values of another of the properties of 'myObject' and executing a separate sql query for each of these possible values.
presumably there is something like a 'query planner' which is converting the hql to sql - and has decided that the 'best' way to do thi is to execute a huge number of separate queries.
Why would NHibernate do this ? - and how can it be dealt with ?
|