使用存储过程还是不使用这是问题 [英] to use stored procedure or not to use that is the question

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

问题描述

大家好,我正在构建一个使用sql server Express Edition的Windows应用程序.该方案是sql server express将不会在专用服务器上运行,而是在常规桌面(可能是专用桌面)上运行.

在这种情况下,我应该使用存储过程,还是应该将与proc相关的存储任务卸载到在客户端计算机上运行的业务逻辑层,该事务对sql进行调用.

我什么时候可以期待良好的表现

解决方案

如果您不使用存储的proc,则不会影响性能,但是如果您不这样做,那么至少要写一个数据层来保存和抽象出所有数据库访问权限.


如果您在客户端计算机上运行SQL Server,建议您使用SQL Server CE,因为它不需要.Net Framework之外的安装.由于SQL Server CE不支持存储过程,因此我将不使用它们.

但是,如果您确实计划使用SQL Server Express,那么我想说使用存储过程的缺点很少,因此您也可以使用它们.一方面,您会获得一些优化(例如,缓存的查询计划),而对于普通查询而言,有时是不存在的.但是,如果性能不是一个大问题,那么普通查询就可以了.

自然,您应该在SP或查询周围写一个数据访问层.无论哪种方式,数据访问层的调用者都不应该知道底层的SQL.


Hi all I am building an windows application which makes use of sql server express edition. The scenario is sql server express will not be running on dedicated servers but on regular desktops(may be a dedicated desktop).

should I use stored procedures in this scenario or should I offload the stored proc related tasks to the Business logic layer which runs on the client machine which makes the call to the sql express.

when can I expect good performance
while using sp or while running the code from the BL layer.

解决方案

If you don''t use stored procs, it shouldn''t affect performance, but if you don''t, then at least write a data layer to hold and abstract out all your database access.


If you are running SQL Server on the client machine, I recommend you use SQL Server CE, as it does not require an installation beyond the .Net Framework. Since SQL Server CE does not support stored procedures, I would then not use them.

If, however, you really do plan on using SQL Server Express, then I''d say there are few disadvantages to using stored procedures, so you might as well use them. For one, you get optimizations (e.g., cached query plans) that are sometimes not there with plain queries. However, if performance is not a much of a concern, then plain queries may be just fine.

Naturally, you should write a data access layer around your SP''s or your queries... either way, the caller of your data access layer should not be aware of the underlying SQL.


这篇关于使用存储过程还是不使用这是问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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