firehose记录集与断开连接的记录集?

时间:2019-10-30 08:35:39

标签: sql-server ado

仅查询数据时(无需进行中间化,移动上一个记录,不设置recordcount属性...),通常认为firehose记录集(CursorType = adForwardOnly,CursorLocation = adUseServer,LockType = adLockReadOnly)是最有效的方法从Microsoft SQL Server返回数据 (例如Performance Tuning Tips for Creating Visual Basic Applications Using SQL Server;

但是,我还发现许多文章(包括上一个链接中的同一篇文章)提到了类似的内容:

SQL Server can only open one ForwardOnly cursor per connection. 
The more connections you create, the greater the stress on SQL Server,
and performance and scalability suffer.
...
To avoid this problem, don’t use a ForwardOnly recordset.

这是另一篇类似的文章:Q258697: INFO: Single SQL Connection Supports Only One Active Firehose

此外,还有一篇文章:Server Side Cursors and ADO Cursor Types提到了

One of the unexpected downside of server-side cursors is temporary tables.
...
This generated significant contention in tempdb
and was forcing the system to single-thread
through object creation in tempdb.

所以我开始认为,如果firehose记录集确实是最好的解决方案(即使只是简单地查询数据)。

然后我发现一些文章(例如How to create disconnected ADO RecordsetsUsing Disconnected Recordsets)提到了“断开记录集”的概念(CursorLocation = adUseClient,ActiveConnection = Nothing)。

尽管我发现了类似的问题,但似乎仍然不够: [recordset using

PS:我测试了该文章中的代码:

rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly

尽管CursorType被分配给adOpenForwardOnly,但是当CursorLocaton被分配给adUseClient时,创建的记录集的CursorType将变为adOpenStatic(就像正式的Microsoft文档:CursorType Property (ADO)

If a provider does not support the requested cursor type,
it may return another cursor type.)

虽然通常认为firehose记录集是从Microsoft SQL Server返回数据以进行简单查询的最有效方法,但是对于3层ERP系统(使用ADO 2.5访问Microsoft SQL Server),肯定会有多个用户通过中间层对象访问Misrosoft SQL Server。 看来,从Microsoft SQL Server使用firehose记录集访问数据将导致创建更多连接,并在DBServer上消耗更多资源。

所以我的问题是:

在这种情况下,断开连接的记录集实际上是否比firehose记录集更好?

0 个答案:

没有答案
相关问题