我正在尝试在asp.net中绑定gridview,但它花了我太多时间。我正在使用存储过程,但在microsoft sql server管理工作室中,存储过程只需2-3秒。我的问题是当我加载asp页面。填充我的gridview需要20-30秒......任何想法?
更新:我的问题在于我的存储过程
SELECT
ROW_NUMBER() OVER
(
ORDER BY A.[ActiuniNumar] DESC
) as RowNum,
A.[Id],
A.[Societate_Id],
A.[Denumire],
A.[NrORC],
A.[CUI],
A.[CNP],
A.[Adresa],
A.[Localitate],
A.[Judet],
A.[Tip],
A.[ActiuniNumar],
A.[ActiuniSerie],
A.[ActiuniNumar] * [ValoareNominala] AS [ActiuniValoare],
CASE
WHEN S.[Capital] = 0 THEN 0
ELSE CAST(A.[ActiuniNumar] * 100 / S.ActiuniNumar AS decimal(18, 8))
END AS [ActiuniProcent],
A.[ActiuniNevandabileNumar],
A.[ActiuniNevandabileSerie],
A.[Diverse],
A.[SerieCI],
A.[Deleted],
A.[ModifiedBy],
A.[ModifiedAt]
INTO #Results2
FROM [dbo].[Actionar] A
INNER JOIN [dbo].[Societate] S ON A.[Societate_Id] = S.[Id]
WHERE 1 = 1
AND ((@ActiuniNumar IS NULL AND 1 = 1) OR (@ActiuniNumar IS NOT NULL AND (@ActiuniNumar = 0 AND A.[ActiuniNumar] <= 0) OR (@ActiuniNumar != 0 AND A.[ActiuniNumar] > 0)))
AND [Societate_Id] = @Id
AND ((@Filter = '' AND 1 = 1) OR (@Filter != '' AND (A.[Denumire] LIKE @Filter OR A.[NrORC] LIKE @Filter OR A.[CUI] LIKE @Filter OR A.[CNP] LIKE @Filter OR A.[ActiuniNumar] LIKE @Filter OR A.[SerieCI] LIKE @Filter)))
and A.[Deleted] = 0
ORDER BY A.[ActiuniNumar] DESC
SELECT * FROM #Results2 where RowNum BETWEEN(@pageIndex -1) * @pageSize + 1 AND(((@pageIndex -1) * @pageSize + 1) + @pageSize) - 1
跑我需要20秒..
答案 0 :(得分:0)
...
and A.[Deleted] = 0
--ORDER BY A.[ActiuniNumar] DESC
评论 ORDER BY 。这会让它变慢。