Simple get using NHibernate (using mapping-by-code) is extremely slow

人盡茶涼 提交于 2019-12-06 01:19:27

Found the issue and solution blogged here by Deep Shah.

Essentially, parameterized queries in NHibernate with the microsoft driver for oracle was the reason for the bottleneck.

He goes on to share two solutions:

  1. Replace the current Microsoft oracle driver with an oracle developed Oracle Data Client Driver. Running the same query using new driver eliminates the performance bottelneck. For this to work you will need to have Oracle Data Access Components (ODAC) installed on the machine from which you intend to fire the query.

  2. When setting a parameter on the query via NHibernate use "query.SetAnsiString" instead of "query.SetParameter" when querying against VARCHAR columns.

I have verified both solutions and they both work. Solution one is the one I went with, since I am using mapping-by-code and I am leaving the query generation to nHibernate.

JeffreyABecker

I believe you can also set the data type to ansi string in your mapping as referenced in this post: NHibernate 3 specify sql data type with loquacious syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!