2
votes

I'm trying to build a pretty simple RSS aggregator using Azure Table Storage, Azure Website and Azure WebJobs.

Lets say my table storage looks like this,

PartitionKey RowKey
A ----------------- 1
A ----------------- 5
A ----------------- 6
B ----------------- 2
B ----------------- 4
B ----------------- 7

I'm using this method, http://blog.liamcavanagh.com/2011/11/how-to-sort-azure-table-store-results-chronologically/ to set RowKeys.

And the PartitionKey is an unique identifier of each feed.

Now, if I would like to have the three newest items (A1, B2 and B3). Is it possible to do a query on two PartiotionKeys and then order by the RowKey?

1
If I understand correctly, you got 3 new feed items (1 in A, and 2 in B) and what you want to do is query table to get just these new feeds. Am I correct? - Gaurav Mantri
My question is, is it possible to do a query that only sorts on RowKey and ignoring the PartitionKey? - Nordis
I don't think so. By default a query result is sorted by PartitionKey first and then RowKey for a PartitionKey even if you don't include PartitionKey in your query. Would it be an acceptable solution if you denormalize your data and store multiple copies of same data? - Gaurav Mantri

1 Answers

1
votes

Put the RowKey in reverse. Instead of 1, 5, 6, etc... start with an impossibly high value (maxint) and then subtract from it. For your case, to keep from having to juggle an arbitrary ID value, perhaps instead use datatime "ticks" as the seed value.

Here's a fairly old example I did of accomplishing something that seems similar to what you're after: http://brentdacodemonkey.wordpress.com/2011/07/08/kicking-off-a-year-of-azureweek-1/