Why is parameterized SQL generated by NHibernate just as fast as a stored procedure?

前端 未结 13 2512
独厮守ぢ
独厮守ぢ 2020-12-14 20:47

One of my co-workers claims that even though the execution path is cached, there is no way parameterized SQL generated from an ORM is as quick as a stored procedure. Any hel

13条回答
  •  遥遥无期
    2020-12-14 21:25

    The additional layer of abstraction will cause it to be slower than a pure call to a sproc. Just by the fact that you have additional allocations on the managed heap, and additional pushes and pops off the callstack, the truth of the matter is that it is more efficient to call a sproc over having an ORM build the query, regardless how good the ORM is.

    How slow, if its even measurable, is debatable. This is also helped by the fact that most ORM's have a caching mechanism to avoid doing the query at all.

提交回复
热议问题