性能明智,这是ADO.NET中更快的连接架构或断开连接的架构 [英] Performance wise which is faster connected architecture or disconnected architecture in ADO.NET

查看:52
本文介绍了性能明智,这是ADO.NET中更快的连接架构或断开连接的架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ado.net包含两个架构



1.connected架构

2.断开连接架构





表现明智,这是更快的连接架构或ado.net中断开的架构



我是什么尝试过:



Ado.net包含两个架构



1.connected Architecture

2.断开连接的架构





性能明智,这是更快的连接架构或ado.net中断开的架构

Ado.net contain two Architecture

1.connected Architecture
2. disconnected Architecture


performance wise which is faster connected Architecture or disconnected Architecture in ado.net

What I have tried:

Ado.net contain two Architecture

1.connected Architecture
2. disconnected Architecture


performance wise which is faster connected Architecture or disconnected Architecture in ado.net

推荐答案

两者都没有。取决于代码和数据的情况,正在解决的问题以及解决问题的方法。这里没有一种架构适用于所有人的方法。



将应用程序持续连接(连接架构)到SQL Server是一个不错的想法。您正在占用SQL Server的许可和其他资源,并迫使您的应用程序和服务器进入无法扩展的位置。



您应该打开连接尽可能晚,做你的查询工作,然后尽早关闭连接。



话虽如此,你打开一个连接并保持打开的频率取决于您对数据执行的操作。



如果INSERT有数千条记录,那么为每个操作打开和关闭连接的性能都很高。您应该尽可能地处理所有数据,打开连接,执行所有INSERT操作,然后关闭连接。



保持连接打开所有time,限制因资源而在服务器上打开的连接数。您还有更复杂的代码,因为如果连接在应用程序生命周期中的某个时间被破坏了怎么办?您将如何处理检测并重新建立连接?
Neither. Depends on the circumstances of the code and data, the problem being solved, and the approach to solving it. There is no "one architecture works for all" approach here.

Having your application constantly connected (connected architecture) to the SQL Server is a BAD idea. You're hogging licensing and other resources of the SQL Server and forcing your application and the server into a position where it scales poorly.

You should be opening a connection as late as possible, doing your query work, then closing the connection as early as possible.

Having said that, how often you open a connection and keep it open depends on the operation your performing on the data.

If you've got thousands of records to INSERT, opening and closing a connection for each of those operations is costly to performance. You should process all of the data as much as possible, open the connection, do all of the INSERT operations, then close the connection.

Keeping a connection open all the time, limits the number of connection you can have open on the server because of resources. You also have more complex code because what if the connection is broken some time during your applications lifetime? How are you going to handle detecting and reestablishing the connection?


这篇关于性能明智,这是ADO.NET中更快的连接架构或断开连接的架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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