首页 > 解决方案 > 用于缓存 API 响应的简单基于 EF 的表花费的时间太长

问题描述

我使用 EF 构建了一个简单的表,用于在我的 ASP.net Web 应用程序中缓存一些 API 请求,以便我可以提高发出相同 REST 调用的请求的性能。

该表有 4 行测试数据。当我在 SQL Server Management Studio 中对所有列进行简单的 SELECT 查询时,加载需要 5-7 秒。如果我在 SELECT 查询中跳过“CachedData”,它会立即加载。我可以做些什么来提高我的表现。我知道 CachedData 可以是大的 JSON 字符串,但我之前看到过更长的字符串在其他表中工作得更快。我错过了什么吗?

这是我的对象/表结构 -

public class APIDataCache
{
    //Using Composite keys. 

    [Key]
    [Column(Order = 1)]
    public string TransactID { get; set; } //nvarchar(128), Not Null

    [Key]
    [Column(Order = 2)]
    public string ResourceID { get; set; } //nvarchar(128), Not Null

    [Key]
    [Column(Order = 3)]
    public string APIDataLevel { get; set; } //nvarchar(128), Not Null

    public string CachedData { get; set; } //nvarchar(max), Nullable

    public DateTime CachedAtTime { get; set; }//datetime, Not Null
}

标签: asp.netsql-serverperformanceentity-framework

解决方案


推荐阅读