I'm facing an issue with azure table storage. I have hundreds of thousands of data into the storage table that I need to query.
First approach is to retrieve all the data and then queried as per the requirement but its taking too much time.
Second approach is what if I get filtered data from table storage directly using query
So as per my understanding second approach is best but I am not able to query appropriately. How can I retrieve the last entry from Azure table storage, in this I am also trying to MAX and order by function but its not work for me.
Not running code:
var query2 = new TableQuery().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, patientId.ToString()),
TableOperators.And,
TableQuery.GenerateFilterConditionForGuid("DeviceID", QueryComparisons.Equal, deviceId))
).OrderByDescending(x=>x.EventDate).Take(1).Select(x=>x.EventDate).ToList();
Running code which taking too much time:
var query = new TableQuery<TherapyEvent>().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, patientId.ToString()),
TableOperators.And,
TableQuery.GenerateFilterConditionForGuid("DeviceID", QueryComparisons.Equal, deviceId)) );
var resp= _table.ExecuteQuery(query).OrderByDescending(x=>x.EventDate).Take(1).Select(x=>x.EventDate).ToList()