You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

带时间戳筛选的Azure Table Storage查询分页大小不一致问题

Azure Table Storage复合筛选分页结果异常问题

我们搭建了Azure Table Storage用于存储不同组织的大量数据,将组织ID作为分区键。部分操作需要获取某组织近24小时的数据,因此编写了如下分页处理大数据集的代码,预期每页返回1000条实体。

仅按分区键筛选时代码运行正常,每页返回1000条实体;但添加Timestamp筛选条件后,分页结果变得不一致,部分页返回100条、60条,甚至0或1条。我们怀疑是SDK存在Bug,想请教:

  • 是否有其他人遇到过该问题?
  • 是否有已知的解决方法或修复方案?
  • 这是SDK处理复合筛选的问题,还是代码逻辑存在错误?
public async Task<IEnumerable<T>> RetrieveEntitiesWithDailyFilterAsync(string tableName, string partitionKey)
{
    List<T> entities = new List<T>();
    //List<TableEntity> entities = new List<TableEntity>();
    string continuationToken = null;

    // Calculate the date and time 24 hours ago from now
    DateTime fromDate = DateTime.UtcNow.AddHours(-24);

    // Build the predicate to filter by PartitionKey and Timestamp
    var predicate = PredicateBuilder.Build<T>(x => x.PartitionKey == partitionKey);
    //for daily
    // predicate = predicate.AndAlso(x => x.Timestamp >= fromDate);
   
    do
    {
        
        var _tableClient = _tableServiceClient.GetTableClient(tableName);

        // Query the table with the predicate and maxPerPage
        var queryResult = _tableClient.QueryAsync<T>(predicate, maxPerPage: 1000);

        // Iterate through pages of results
        await foreach (var page in queryResult.AsPages(continuationToken))
        {
            continuationToken = page.ContinuationToken;
            entities.AddRange(page.Values);
        }
    } while (!string.IsNullOrEmpty(continuationToken));

    return entities;
}

内容的提问来源于stack exchange,提问作者Utpal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 05:12:10