从EntitySpaces加载存储过程所花费的时间是从SQL客户端加载存储过程的40倍
本文关键字:存储过程 加载 40倍 SQL 客户端 EntitySpaces 时间 | 更新日期: 2023-09-27 18:21:58
我正在处理一个使用EntitySpaces作为ORM的项目。
下面您将看到ItemCollection的一个简化方法,该方法通过调用存储过程来加载集合:
public partial class ItemCollection : esItemCollection
{
public bool LoadItemsUsingSomeStoredProcedure(string aLotOfAttributes, out int totalCount)
{
// Set a lot of parameters
esParameters parameters = new esParameters();
// ...
bool result = Load(esQueryType.StoredProcedure, "ItemsStoredProcedure", parameters);
totalCount = (int) paramTotalCount.Value;
return result;
}
}
使用SQL Server Profiler,我看到这就是对数据库调用的结果:
declare @p5 int
set @p5=485
exec [ItemsStoredProcedure] @Param1=4,@Param2=N'41',@Param3=N'SomeValue',@Param4=0,@TotalCount=@p5 output,@Param5=1,@Param6=25
select @p5
大约需要200秒才能完成。
但是:当我在SQL Management Studio中(本地和远程)运行相同的SQL片段时,大约需要4到5秒才能完成。
有什么想法吗?为什么EntitySpaces调用的完成时间是SQL客户端调用的40倍?有什么想法可以调试/改进吗?
PS:替换EntitySpaces是我的首要任务,但和往常一样,很难说服客户花一个月的时间来重构一个"有效"的程序。。。所以这个选项已经过时了,atm。
不要从Visual Studio运行它,这是所有应用程序的已知问题,EntitySpaces几乎没有向SqlClient添加任何时间,并且实现了所有ORM中最快的时间。
http://www.entityspaces.net/www.entityspaces.net/blog/2010/08/26/The%20EntitySpaces%20ORMBattleNET%20Performance%20Numbers.aspx.html