SQL 查询在 C# 中执行速度很慢,但在 Toad 中执行速度很快 [英] SQL Query executes slow in C#, but fast in Toad

查看:83
本文介绍了SQL 查询在 C# 中执行速度很慢,但在 Toad 中执行速度很快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SQL 查询,它在 Toad 中在几秒钟内执行(<4),但是使用它运行时大约需要 8 分钟C# (System.Data).

I have a SQL query which executes within seconds (< 4) in Toad, but it takes around 8 mins when run using C# (System.Data).

可能是什么原因?如何解决?

SQL 查询

SELECT TAB1.COL1, TAB1.COL2  
FROM   TAB1, TAB2 
WHERE  TAB1.COL1 = TAB2.COL1 
AND    COL2 IN (...)

C# 代码

this.DbAdapter.Select(cmdText, dbparams,
                      "TAB1", this.dbConnection.Transaction);

<小时>

我已经提到但没有帮助的内容:


What I referred already and does not help:

推荐答案

System.Data.OracleClient 被贬低和糟糕.使用 Oracle 的 ODP.net(如果您可以控制或了解已部署机器上的客户端设置)、托管 ODP.net(如果您无法控制运行程序的机器上的客户端)或 Dev Art 的 dotConnect for Oracle.

System.Data.OracleClient is depricated and terrible. Use Oracle's ODP.net (if you can control or know the client setup on the deployed machine), managed ODP.net (if you can't control the client on the machine where the program will run) or Dev Art's dotConnect for Oracle.

http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

我以前使用 System.Data.OracleClient ,有各种神秘的停顿、延迟和无法解释的现象.例如,简单地调用绑定变量会导致任何查询的执行延迟 17 秒(我们对其进行了计时).

I used System.Data.OracleClient back in the day, and there were all sorts of mystery pauses, delays, and unexplained phenomena. For example, simply invoking a bind variable caused a 17 second delay in the execution of any query (we timed it).

诚然,8 分钟是令人震惊的,但作为第一次通过,请切换您的司机,看看离您有多近.

Admittedly, 8 minutes is shocking, but as a first pass switch your driver and see how much closer that gets you.

这篇关于SQL 查询在 C# 中执行速度很慢,但在 Toad 中执行速度很快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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