Hi,
I have noticed that NH doesn't batch up updates as effectively as it could (and does on inserts). Specifically when the entity graph hits a level such as "parent -> child collection -> child", NHibernate will issue updates like:
Parent 1
-> Batch updates on Parent 1's children
-> Batch updates on Parent 1's children children
Parent 2
-> Batch updates on Parent 2's children
-> Batch updates on Parent 2's children children
Parent 3
-> Batch updates on Parent 3's children
-> Batch updates on Parent 3's children children
The system I am currently working on ends up performing actions on multiple items (for example pricing 50 pieces of stock), which can result in 100 queries to the database.
Without wanting to argue the use of nhibernate for this kind of operation, I have noticed a property called "IsOrderUpdatesEnabled" on the session class which is never set. Altering the configuration classes to allow this to be set results in a big improvement with batching such operations. The updates now issue like:
Batch updates on all Parents
Batch updates on all Parent's children
Batch updates on all Parent's childrens children
i.e. 3 queries instead of, in this scenario with 3 top level entities, 9.
My question is, is there a reason why this property is not set from the SettingsFactory class, and if not, would anyone be interested in a PR to allow it to be set? Or have I overlooked some way to set it!
I haven't come across any issues when running locally with it switched on.
Thanks,
Graeme