Optimize retrieving rows from Azure Table using partition key and row key with Range

94 Views Asked by At

Background: I have a C# project where I need to retrieve records based on the partition key and row key with a range from an Azure Table (that has more than 5,00,000 rows with multiple partition keys and the row key is a timestamp when this row is recorded).

I'm using ExecuteQuerySegmentedAsync with the table query as shown below under the code section.

Problem:

  1. The time it takes to get approx. 20k rows (with a specific partition key and row key range) is approx. 20 seconds. Can this be optimized?
  2. The time increases when I send multiple requests with different partition keys at the same time. It takes approx. 45 seconds - 1 minute for each request to complete to return approx 20k rows each. Why is this taking so long if I send multiple requests? Is there a different approach how to handle multiple requests or increase performance.?

Code:

tableQuery = PartitionKey eq '3dd373c2-dbf6-4d7a-81da-1ec69b652ca2' and RowKey le '2517379523999999999' and RowKey ge '2517367427999999999'

    do
    {
        tableRows = await table.ExecuteQuerySegmentedAsync(tableQuery, tableContinuationToken);
        rows.AddRange(tableRows.Results);
    
        tableContinuationToken = tableRows.ContinuationToken;
    
    
    } while (tableContinuationToken != null);
0

There are 0 best solutions below