ORM and when query plans go bad
D. Mark Lindell has a few questions about sclaing ORM:
- How can dynamic SQL ORMs deal with the fact that your database server (a.k.a SQL Server) can decide at any point that it is going to use an alternate query plan. A simple index HINT on the join syntax can fix this problem but how is my ORM going to handle this?
- How come there is no talk about scaling these ORMs. No, I'm not talking about scaling the database. A layer between the ORM and the database execution.
The answer to the first question is easy, you use index HINT when you need it. NHibernate makes it very easy to plug in your SQL (and I have several posts about - here is one) when the default approach is not sufficent, the 1.2 release goes beyond just leting you specify you SQL for queries, it lets you specify custom SQL for just about anything (Entity - CRUD, Collection - CRUD, etc).
I am not sure that I understand the second question at all, though.
Comments
Maybe he's talking about connecting to multiple RDBMSes? Or do ORMs generally allow that anyway?
Yes, most ORM has no issue with that.
I didn't explain myself very well on question #2. I tend to design my business objects around a UI centric use case. I use them at the UI tier and don't hide them behind services. This allows me to to maximize the productivity gained by data binding. If my BOs use an ORM that connects directly to the database is there an option to scale these objects when used at the UI layer?
This is the CSLA approach.
Thanks for the response on question #1. I'm new to NH and am learning it in my spare time.
Sorry to hijack the topic a bit but, you said you can use custom SQL for just about anything - what about properties of an object in the mapping file? eg I have some properties that are calculated in SQL, is there a way to populate these automatically using the mapping file? and if so can this use lazy loading?
Sorry again for hijacking, and if these are obvious - I'm new to this too!
No lazy loading for those properties, but you can use formulas to have calculated properties.
To be more exact, you get lazy loading for the properties on the object level, not on a per property level.
Comment preview