A table with 20 columns (ints, bools and varchar(50)'s) retrieve is very slow because of one column with the type of varchar(max).
The table has 680 rows, and i 'm retrieving max 5 or 6 results.
For some reason the select statement is very slow if the result contains a column with type varchar(MAX).
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; We have moved the contents (schema & data) of the table from one server to another using a scriptfile.
Any idea's how this is possible?
// Inserting more information. Ok, the plot thickens.
Created indexes, but it doesn't make any (noticeable) performance boost.
I'm getting it on more databases (same server) now. Take the following query from the profiler (query from entity framework):
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
This sometimes increases loading time. No matter the amount of records, it's always increases around 16-18 seconds loading time.
The complete sql server is not handling any requests (to other databases too), so it causes all the sites to block and wait untill this operation is done, and then continues.
Almost like it's filling memory with each request!
Server specs are fair enough; webserver 8gigs ram, sql has the same. Currently hosting about 20 sites on IIS7 (all .net MVC using EF 5)