gpt4 book ai didi

c# - Linq-to-SQL 实现速度非常慢

转载 作者:太空宇宙 更新时间:2023-11-03 12:53:32 26 4
gpt4 key购买 nike

我的 .aspx 页面加载时间不佳,目前我正在尝试对其进行优化。首先,我使用 Visual Studio Performance AnalyzerSQL Server Profiler 来查找慢的地方,然后我将 Stopwatches 直接放在我的代码中。

不太明白是怎么回事,但看起来整个应用程序中最慢的方法是物化方法,但只有三个小表才慢:

internal T[] GetTableAsArray<T>() where T : class
{
return dataContext.GetTable<T>().ToArray();
}

第四张 table 没问题。 SQL Server Profiler 显示 SQL 查询的 Duration 为零,但我的 Stopwatch 显示 677ms、884ms、355ms 和 8ms。所有表格都是约 50 行和约 7 列。

有什么想法吗?我应该在哪里挖掘?

最佳答案

先生们,复杂的继承就是答案。此处描述了相同的问题:.NET Linq to SQL Performance Issue with Inherited Discriminators .我的慢表有 child ,快表没有。

关于c# - Linq-to-SQL 实现速度非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34744524/

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