gpt4 book ai didi

c# - SQL脚本需要很长时间才能运行

转载 作者:太空狗 更新时间:2023-10-29 23:46:45 25 4
gpt4 key购买 nike

我目前正在使用 Microsoft Enterprise Library Data Access 5.0 来执行存储过程。

Database myDatabase = DatabaseFactory.CreateDatabase();
using (DbCommand command = myDatabase.GetStoredProcCommand("myStoredProc"))
{
//Add parameters here
using (IDataReader dataReader = myDatabase.ExecuteReader(command))
{
while (dataReader.Read())
{
}
}
}

一切正常,但需要很长时间才能运行。当我打开 SQL Profiler 时,我可以看到存储过程大约需要 50 秒才能运行。但是,如果我从探查器中获取相同的脚本并在 SQL Management Studio 中运行它,返回所有行只需要大约 480 毫秒。

有人遇到过这个问题吗?为什么会有这么大的差异?

最佳答案

很容易成为Parameter Sniffing .

关于c# - SQL脚本需要很长时间才能运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15147151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com