Azure table storage: order

I am creating a wishlist website. I want to save the wish list in the azure table store, but I also want the user to be able to sort his wish list when viewing it, in several different ways - added date, date added in the opposite direction, item name, etc. I also want to implement swap, which I think I can implement using the continuation token.

As I understand it, the "order" is not implemented, and the order returned by the results from the table store is based on the section key and key line. Therefore, if I want to implement the paging and sorting that I am describing, is the best way to implement this by storing the wish list several times using the partition key / key?

In this simple case, most likely, the wish list will not be so large, and I could actually limit the maximum number of elements that can appear in the list, and then get rid of paging and sorting in memory. However, I have more complex cases where I also need to implement swap and sort for.

+7
source share
4 answers

On today's hardware with 1000 lines to store, the list, in memory and sorting is easy to maintain. What is the real problem, how far is it possible for you to access the rows in the table store using the keys and not scan the table. Duplicating rows across multiple tables can become quite cumbersome to maintain.

An alternative solution would be to temporarily place your rows in SQL Azure and apply order there. This can be effective if your result set is too large to work in memory. For best results, the temporary table should have the necessary indexes.

+8
source

Why not do it all in .net using a list.

For this type of application, I would think that SQL Azure would be more appropriate.

+2
source

Azure Storage stores objects in lexicographical order, indexed by section of the section as the primary index, and Row Key as the secondary. In general, for your scenario, this sounds like UserId is great for a section key, so you have a Row Key to optimize for each request.

If you want the user to browse the wish lists from above, you can use the journal tail template in which your string key will be the inverted date type in DateTime when the user wish list was entered by the user. https://docs.microsoft.com/en-us/azure/storage/storage-table-design-guide#log-tail-pattern

If you want the user to see their wish lists sorted by item name, you could specify your name as a keyword, and thus entities will be sorted by azure.

When you write data, you may want to denormalize the data and make several entries using these different line string schemes. Since you will have the same partition key as the user ID, you can perform the insert operation in batch loading at this stage and not worry about consistency, since the operations of the azure batch table are atomic.

To distinguish between different line patterns, you can add each value with a const string. Like your inverted tick string key value, for example woul dbe, for example, "InvertedTicks_ [InvertedDateTimeTicksOfTheWishList]", and the item name string key value will be "ItemName_ [ItemNameOfTheWishList]"

0
source

Something like this did a great job with me:

List<TableEntityType> rawData = (from c in ctx.CreateQuery<TableEntityType>("insysdata") where ((c.PartitionKey == "PartitionKey") && (c.Field == fieldvalue)) select c).AsTableServiceQuery().ToList(); List<TableEntityType> sortedData = rawData.OrderBy(c => c.DateTime).ToList(); 
-one
source

All Articles