Search code examples
c#visual-studio-2010azurewcf-ria-services

Optimizing Azure Storage queries for RIA services


I'm working with Azure Storage Tables and RIA services to create a, rather basic, Silverlight UI to access and manage some of the data.

Nothing too fancy: a data model with some annotations, and a DomainDataSource, make it all a breeze.

With one minor exception.

When I have a really, really large table, then loading it, at least when I'm doing this on the Development Fabric and even using the LoadSize parameter of the DomainDataSource, takes a LOT of time.

My guess is that the following thing happens:

  • The Silverlight client asks the RIA service for, say, 100 first rows of the table.
  • Since Azure Data Storage queries are extremely basic, the service retrieves all the rows from the data storage, and THEN performs Take(100) on that set.
  • Client gets the first 100 rows.

This is OK for conserving bandwidth, but it's far from optimal when you consider that one must pay for processing power used by an Azure-based application.

Is there any way to optimise the RIA service queries? Is it even at all possible to use Take() and Skip() methods on Azure Storage Tables?

EDIT: I am using WCF RIA Services SP1 Beta, and have followed several tutorials on Silverlight with RIA services (which are all very very similar). Combining the two, I'm simply wondering if loading a large table into Silverlight can be improved by adding the LoadSize parameter. At the moment it seems to conserve bandwidth only (as the correct amount of rows is being sent to the Silverlight client), but the whole process still uses as much CPU time as it does for the whole table.


Solution

  • Have you tried RIA Services SP1 Beta? It includes TableDomainService that handles all the logic by managing entities in the specified Azure Storage account. Also, you can inspect traffic between your service and Azure Storage using Fiddler to find out what the problem is.

    References:

    • WCF RIA Services SP1 Beta announcement
    • Kyle McClellan's blog - he is the person who developed TableDomainService. There are a lot of posts in his blog about this feature.

    EDIT: As Kyle McClellan mentioned below in the comment, this problem really exists in WCF RIA Services SP1 Beta.