当使用存储过程,而不是使用与编程逻辑的ORM的? [英] When to use Stored Procedures instead of using any ORM with programming logic?
问题描述
大家好,我想知道我什么时候应该更喜欢编写程序逻辑和使用ORM或别的东西拉数据写入存储过程。
存储过程在服务器端执行
这意味着,处理大量数据的不要求通过网络连接传递这些数据。对>
此外,使用存储过程,你可以建立一致的复杂的业务逻辑。
我说,你需要更新账户余额每次插入一个交易,你需要在一次插入许多交易。
而不是使用触发器这样做(这是使用效率不高的记录逐个记录的方式实现在许多系统中),你可以通过与输入表变量或临时表,并发出在过程中基于集合的 SQL
语句。这将是更加高效。
Hi all I wanted to know when I should prefer writing stored procedures over writing programming logic and pulling data using a ORM or something else.
Stored procedures are executed on server side.
This means that processing large amounts of data does not require passing these data over the network connection.
Also, with stored procedures, you can build consistent complicated business logic.
Say, you need to update the account balance each time you insert a transaction, and you need to insert many transactions at once.
Instead of doing this with triggers (which are implemented using inefficient record-by-record approach in many systems), you can pass a table variable or temporary table with the inputs and issue a set-based SQL
statement inside the procedure. This will be much more efficient.
这篇关于当使用存储过程,而不是使用与编程逻辑的ORM的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!