当使用存储过程,而不是使用与编程逻辑的ORM的? [英] When to use Stored Procedures instead of using any ORM with programming logic?

查看:86
本文介绍了当使用存储过程,而不是使用与编程逻辑的ORM的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想知道我什么时候应该更喜欢编写程序逻辑和使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆