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

前端 未结 13 2563
独厮守ぢ
独厮守ぢ 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:12

    I would only add a couple things to Rob's answer:

    First, Make sure the amount of data involved in the test cases is similiar to production values. In other words if your queries are normally against tables with hundreds of thousands or rows, then create such a test environment.

    Second, make everything else equal except for the use of an nHibernate generated query and a s'proc call. Hopefully you can execute the test by simply swapping out a provider.

    Finally, realize that there is usually a lot more at stake than just stored procedures vs. ORM. With that in mind the test should look at all of the factors: execution time, memory consumption, scalability, debugging ability, etc.

提交回复
热议问题