Do Azure storage tables contain RowKeys individually indexed to take advantage of child queries?

I need to know if the Azure Storage tables were indexed by RowKey separately from PartitionKey in order to fulfill this kind of query ...

Assumption. In my table there are forum posts containing PartitionKey = UserEMail, RowKey = PostInstant. So, I want to request like this ...

SELECT data FROM forum WHERE PartitionKey=" user@company.com " AND RowKey < DateLimit; 

(Note: I know that PostInstant needs to be written “inverted” in order to take advantage of the upward sort and thus get it in descending order, this is not the point).

As I understand it, by explicitly specifying PartitionKey, the request goes well along the performance path, but after that ... will RowKey be reasonably used to: a) give the results sorted and b) stop the scan after reaching DateLimit?

Or, in other words, does the indexing of the Azure Storage Table apply to the concatenation of PartitionKey + RowKey, so is it only useful for matching rows and completely sorting the table?

+4
source share
2 answers

Yes, the query you wrote is as efficient as you can write it against Azure tables, and it should use indexes for PartitionKey and RowKey .

Your results are guaranteed to return to PartitionKey , then RowKey .

+2
source

PartitionKey and RowKey are currently the only indexed attributes you can use. However, you are using only one in your question. Thus, your query will search for the entire PartitionKey ' user@company.com ' without any further index. If this is a small section, this may not be a big problem. If it is large, then you should also use RowKey. Note that while you specify an attribute called "PostInstant", this is not the same as RowKey. You must specifically query RowKey (even if it is the same as the name of another column).

So your query would look something like this:

 ctx.CreateQuery<Foo>('tablename').Where(s => s.PartitionKey == " user@company.com " && s.RowKey.Compare(DateLimit) > 0); 

I assume, of course, that “DateLimit” is actually a date formatted string (like ticks). If you change the order of the ticks, you also invert the comparison operator (>).

+2
source

All Articles