What actully happened in background if I query for few selected columns from azure table storage

Answered What actully happened in background if I query for few selected columns from azure table storage

  • vendredi 17 février 2012 05:36
     
     

    Consider the following scenario.
    I have 2 classes
    public class clsBig : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
    {
                public string strA{ get; set; }
                public string strB { get; set; }
                public string strC { get; set; }
                public string strD { get; set; }
    }

    public class clsSmall : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
    {
                public string strA{ get; set; }
                public string strB { get; set; }
    }

    Now if I store the multiple rows in azure table by using class "clsBig" and write a query to collect data from table by using class "clsSmall"
    eg: var obj = context.CreateQuery<clsSmall>("clsBig");
    Then my question is, in this case what actually happens in background? Query takes all the data with 4 columns from table and returns it to client then fills only 2 columns data in class "clsSmall" at client end; or it retrieves only mentioned column from table?


     

Toutes les réponses

  • vendredi 17 février 2012 05:50
     
     
  • vendredi 17 février 2012 06:04
     
     

    hi Lucifure,

    I know that & I always set IgnoreMissingProperties= true;

    but my question is, if this query execute successfully then what will be happened?

    case 1- it sends all columns to client and then filter selected columns data & store in class at client end?

    case2- it only sends data of selected columns?

    means, I want to know column filteration is done on server side or client end?

  • vendredi 17 février 2012 06:14
     
     Traitée

    For the code you showed, it's case #1.

    But since last September, table storage supports "query projection," which means the property selection can be done server-side. Try something like context.CreateQuery<clsSmall>("clsBig").Select(b => new clsSmall { strA = b.strA, strB = b.strB });.

    I haven't tried just that, but it's my understanding of http://blogs.msdn.com/b/windowsazurestorage/archive/2011/09/15/windows-azure-tables-introducing-upsert-and-query-projection.aspx. Note that the guidance in that post to use a special TableServiceContextV2 shouldn't be necessary with current versions of the WA storage client library.

    A good way to verify that things are working as you expect is to fire up Fiddler (or another HTTP capture tool) and watch the traffic going back and forth between your machine and table storage. I recommend testing against actual cloud storage rather than the storage emulator, just in case they differ.

    • Marqué comme réponse Atul Bhavasar vendredi 17 février 2012 06:48
    •  
  • vendredi 17 février 2012 17:15
     
     
    Atul,

    The server does not really know which properties to send back unless a projection is used. So it will send back all the properties on the row. The client then determines how to populate the object.

    When a projection is used, the REST call specifies which properties to return back and the server honours that request.

    Bottom line here is that the disconnected nature of the interaction does not allow any assumptions to be made on either side, rather the client request needs to be explicit if it wants only a subset of the row properties. 

    So to answer your second question, it is case 1 unless a projection is used, in which case it is case2

    Ref: http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx