执行查询时出现超时错误
我正在存储过程中执行以下查询,将一年的事务从一个表传输到另一个表:
insert into
table2
select
*
from
table1
where
dates between '20110101' and 20111231'
当我使用 VB6 调用存储过程时,它超时。
我尝试将 RDO 连接上的 QueryTimeout 属性设置为五秒,如下所示:
RdoConn.QueryTimeout = 5000
但它仍然超时。
如何防止查询执行超时?
I am executing the following query in a stored procedure, transferring one year's transactions from one table to another:
insert into
table2
select
*
from
table1
where
dates between '20110101' and 20111231'
When I use VB6 to call the stored procedure, it times out.
I've tried to set the QueryTimeout
property on my RDO Connection to five seconds like so:
RdoConn.QueryTimeout = 5000
But it's still timing out.
How can I prevent the execution of the query from timing out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 Ado 连接,则可以使用以下代码
,然后使用此连接来执行查询。
您的查询需要多长时间才能正常运行?
更新:
使用 RdoConnection,您可以尝试设置 LoginTimeout 事件
或如 所指出的奥列格·多克
If you use an Ado connection you can use the following code
and then use this connection to execute your query.
How much time does your query take to run without issue?
Update:
Using RdoConnection, you can try to set event the LoginTimeout
or as pointed out by Oleg Dok
您的两个选项(不更改数据库模式)是:
1)增加超时时间,例如:
2)如果您的查询执行时间超过 30 秒,那么您应该尝试将 select 语句分解为更小的部分:
如上所述您还应该查看数据库中的索引和数据类型以提高性能
Your two options (without changing the database schema) are:
1) Increase your timeout time eg:
2) If your query is taking longer than 30 seconds to execute then you should probably try breaking down your select statement into smaller parts:
As mentioned though you should also look at indexes and data types in your database to improve performance