我使用Glimpse跟踪我页面上的sql统计信息。
最近我开始在我的几个动作中使用outputcache
。然而,一瞥显示使用outputcache
的页面上的数据库查询数量增加到7,而通常没有outputcache
的数量是2个查询。
这是我的一个行动:
[OutputCache(Duration = 3600)]
public virtual async Task<ActionResult> Index(string searchString, int? page)
以下是查询:
SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[__MigrationHistory] AS [Extent1]
WHERE [Extent1].[ContextKey] = 'MEF.DataLayer.Migrations.Configuration' /* @p__linq__0 */
) AS [GroupBy1]
SELECT TOP (1)
[c].[CreatedOn] AS [CreatedOn]
FROM [dbo].[__MigrationHistory] AS [c]
SELECT
[Extent1].[MigrationId] AS [MigrationId]
FROM [dbo].[__MigrationHistory] AS [Extent1]
WHERE [Extent1].[ContextKey] = 'MEF.DataLayer.Migrations.Configuration' /* @p__linq__0 */
SELECT TOP (1)
[Project1].[C1] AS [C1],
[Project1].[MigrationId] AS [MigrationId],
[Project1].[Model] AS [Model],
[Project1].[ProductVersion] AS [ProductVersion]
FROM ( SELECT
[Extent1].[MigrationId] AS [MigrationId],
[Extent1].[Model] AS [Model],
[Extent1].[ProductVersion] AS [ProductVersion],
1 AS [C1]
FROM [dbo].[__MigrationHistory] AS [Extent1]
WHERE [Extent1].[ContextKey] = 'MEF.DataLayer.Migrations.Configuration' /* @p__linq__0 */
) AS [Project1]
ORDER BY [Project1].[MigrationId] DESC
SELECT TOP (1)
[Project1].[C1] AS [C1],
[Project1].[MigrationId] AS [MigrationId],
[Project1].[Model] AS [Model],
[Project1].[ProductVersion] AS [ProductVersion]
FROM ( SELECT
[Extent1].[MigrationId] AS [MigrationId],
[Extent1].[Model] AS [Model],
[Extent1].[ProductVersion] AS [ProductVersion],
1 AS [C1]
FROM [dbo].[__MigrationHistory] AS [Extent1]
WHERE [Extent1].[ContextKey] = 'MEF.DataLayer.Migrations.Configuration' /* @p__linq__0 */
) AS [Project1]
ORDER BY [Project1].[MigrationId] DESC
SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[Animes] AS [Extent1]
) AS [GroupBy1]
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[EnglishName] AS [EnglishName],
[Extent1].[PersianName] AS [PersianName]
FROM [dbo].[Animes] AS [Extent1]
ORDER BY [Extent1].[EnglishName] ASC
OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY
我错过了什么吗?为什么使用outputcache
?