每次通话后关闭连接?
问题描述:
打击数据库的最有效方法是:1)打开/关闭页面上每次调用数据库的
连接(我们有子网做了
这个); 2)或使用相同的连接并在结束时关闭它?我的感觉是
2更好,但只是想与专家确认。谢谢
advance。
Which is the most efficient way to hit the database: 1) to open/close the
connection for each call to the database on a page (we have Subs that do
this); 2) or use the same connection and close it at the end? My feeling is
that 2 is better, but just wanted to confirm with the experts. Thanks in
advance.
答
我用2)。但是,您的环境可能会有所不同......在启动连接时,您可能会有更多
或更少的开销,您可能会在调用之间执行* $ *
处理等等
当你对最有效的时候感到好奇 - 找出自己,而不是询问意见。你得到的几乎所有意见肯定会遗漏
你忘记提及的一些变量。
关于计时代码的一些提示:
http://www.aspfaq.com/2092
http://www.aspfaq.com/2245
>
压力测试:
http:// www。 aspfaq.com/2139
测量SQL Server性能:
http://www.aspfaq.com/2513
有效开发ASP的一般建议:
http://www.aspfaq.com/2424 >
-
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
" dw" <共*************** @ uncw.edu>在消息中写道
新闻:OO ************** @ TK2MSFTNGP12.phx.gbl ...
I use 2). However, your environment may be different... you may have more
or less overhead when initiating a connection, you might be doing a *lot* of
processing between calls, etc.
When you''re curious about "most efficient" - find out for yourself, rather
than asking opinions. Almost all opinions you get will certainly leave out
some variable you''ve forgotten to mention.
Some tips on timing code:
http://www.aspfaq.com/2092
http://www.aspfaq.com/2245
Stress testing:
http://www.aspfaq.com/2139
Measuring SQL Server performance:
http://www.aspfaq.com/2513
General suggestions for efficient ASP development:
http://www.aspfaq.com/2424
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"dw" <co***************@uncw.edu> wrote in message
news:OO**************@TK2MSFTNGP12.phx.gbl...
哪个效率最高点击数据库的方法:1)打开/关闭页面上每次调用数据库的
连接(我们有Subs这样做)/; 2)或使用相同的连接并在结束时关闭它?我感觉
是2更好,但只是想与专家确认。谢谢
提前。
Which is the most efficient way to hit the database: 1) to open/close the
connection for each call to the database on a page (we have Subs that do
this); 2) or use the same connection and close it at the end? My feeling is that 2 is better, but just wanted to confirm with the experts. Thanks in
advance.
谢谢,Aaron。还要感谢有用的链接:)
" Aaron Bertrand - MVP" < AA *** @ TRASHaspfaq.com>在消息中写道
news:%2 ****************** @ TK2MSFTNGP10.phx.gbl ...
Thanks, Aaron. Also thanks for the useful links :)
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
我用2)。但是,您的环境可能会有所不同......启动连接时可能会有更多或更少的开销,您可能会在呼叫之间进行* $ *
处理等。
你忘记提及的一些变量。
关于计时代码的一些提示:
http://www.aspfaq.com/2092
http://www.aspfaq.com/2245
压力测试:
http://www.aspfaq.com/2139 >
衡量SQL Server性能:
http:// www.aspfaq.com/2513
有效开发ASP的一般建议:
http://www.aspfaq.com/2424
- Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
dw <共*************** @ uncw.edu>在消息中写道
新闻:OO ************** @ TK2MSFTNGP12.phx.gbl ...
I use 2). However, your environment may be different... you may have more
or less overhead when initiating a connection, you might be doing a *lot* of processing between calls, etc.
When you''re curious about "most efficient" - find out for yourself, rather
than asking opinions. Almost all opinions you get will certainly leave out some variable you''ve forgotten to mention.
Some tips on timing code:
http://www.aspfaq.com/2092
http://www.aspfaq.com/2245
Stress testing:
http://www.aspfaq.com/2139
Measuring SQL Server performance:
http://www.aspfaq.com/2513
General suggestions for efficient ASP development:
http://www.aspfaq.com/2424
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"dw" <co***************@uncw.edu> wrote in message
news:OO**************@TK2MSFTNGP12.phx.gbl...
这是最有效的方法数据库:1)打开/关闭
每次调用页面上数据库的连接(我们有Subs这样做)/; 2)或使用相同的连接并在结束时关闭它?我的感觉
Which is the most efficient way to hit the database: 1) to open/close the connection for each call to the database on a page (we have Subs that do
this); 2) or use the same connection and close it at the end? My feeling
是
2更好,但只是想与专家确认。谢谢
advance
that 2 is better, but just wanted to confirm with the experts. Thanks in
advance.
我通常会在连接时使用。
Sub OpenData()
''''创建具有全局范围的ado对象
End Sub
Sub CloseData()
''''''关闭并销毁ado对象
End Sub
OpenData
设置rs1 = adoObject.Execute(无论如何)
'''代码,代码,代码
设置rs2 = adoObject.Execute(whateverElse )
关闭数据
雷在工作
" dw" <共*************** @ uncw.edu>在消息中写道
新闻:OO **************** @ TK2MSFTNGP12.phx.gbl ...
I''ll typically use on connection.
Sub OpenData()
''''create ado object with global scope
End Sub
Sub CloseData()
''''''closes and destroys ado object
End Sub
OpenData
Set rs1 = adoObject.Execute(whatever)
''''code, code, code
Set rs2 = adoObject.Execute(whateverElse)
CloseData
Ray at work
"dw" <co***************@uncw.edu> wrote in message
news:OO****************@TK2MSFTNGP12.phx.gbl...
这是什么打击数据库的最有效方法:1)打开/关闭页面上每次调用数据库的
连接(我们有Subs这样做)/; 2)或使用相同的连接并在结束时关闭它?我感觉
是2更好,但只是想与专家确认。谢谢
提前。
Which is the most efficient way to hit the database: 1) to open/close the
connection for each call to the database on a page (we have Subs that do
this); 2) or use the same connection and close it at the end? My feeling is that 2 is better, but just wanted to confirm with the experts. Thanks in
advance.