具有20列(int,bools和varchar(50))检索的表非常慢,因为一列的varchar(max)类型。
该表有680行,我正在检索最多5或6个结果。
由于某种原因,如果结果包含类型为varchar(MAX)的列,则select语句非常慢。
SELECT Id, Title, Description, FieldType, FieldName, DynamicMenuId, RelatedDynamicMenuId, RelatedDynamicMenuField, RelatedDynamicMenuFieldDisplay,
CustomTableId, Position, ShowInGrid, AllowSelection, DefaultValue, DocumentUploadPath, RelatedWhereClause, RequiresSearch, IsRequired, DataType,
FieldGroupId
FROM dbo.SMDynamicMenuField
WHERE (DynamicMenuId = 55)
FYI;我们已经使用脚本文件将表的内容(模式和数据)从一个服务器移动到另一个服务器。
有什么想法可以吗?
//插入更多信息。 好吧,情节变浓了。
创建索引,但它不会使任何(明显的)性能提升。
我现在在更多数据库(同一台服务器)上获取它。从分析器中获取以下查询(来自实体框架的查询):
exec sp_executesql N'SELECT
[Project1].[Id] AS [Id],
[Project1].[AppartmentId] AS [AppartmentId],
[Project1].[ImageTitle] AS [ImageTitle],
[Project1].[ImageDescription] AS [ImageDescription],
[Project1].[ImageFile] AS [ImageFile],
[Project1].[Position] AS [Position]
FROM ( SELECT
[Extent1].[Id] AS [Id],
[Extent1].[AppartmentId] AS [AppartmentId],
[Extent1].[ImageTitle] AS [ImageTitle],
[Extent1].[ImageDescription] AS [ImageDescription],
[Extent1].[ImageFile] AS [ImageFile],
[Extent1].[Position] AS [Position]
FROM [dbo].[AppartmentImage] AS [Extent1]
WHERE [Extent1].[AppartmentId] = @p__linq__0
) AS [Project1]
ORDER BY [Project1].[Position] ASC',N'@p__linq__0 int',@p__linq__0=56
go
这有时会增加加载时间。无论记录数量多少,它总是会在16-18秒的加载时间内增加。
完整的sql server没有处理任何请求(也是其他数据库),因此它会导致所有站点阻塞并等待直到此操作完成,然后继续。
几乎就像每个请求都在填充内存!
服务器规格足够公平; webserver 8gigs ram,sql也一样。目前在IIS7上托管大约20个站点(所有.net MVC使用EF 5)